Debugging MS Word

I try to fill a bookmark in MS Word with a fields content. No problem, until the bookmark is in the footer area. That raises a OLEException - cannot find bookmark.
I tried to overcome that with

Word.ActiveWindow.ActivePane.View.SeekView = Office.wdSeekCurrentPageFooter Word.Selection.GoTo_(Office.wdGoToBookmark,nil,nil,"DateFooter") Word.Selection.TypeText(ABEndTimeFld.text)

but it still crashes on the wdGotoBookmark. I checked and doublechecked - the bookmark does exist and I can move there without problems in MS Word, but not with Xojo. Any solutions to this?

@Eugene Dakin has writen a usefull ebook “I wish how to program Word 2010 with Xojo in Windows”

Hi Joost,

I bought that book some time ago. In fact my code comes from his book…

What if you code this directly in the internal VBA environment ?

Sub Macro4() ' ' Macro4 Macro ' ' Selection.GoTo What:=wdGoToBookmark, Name:="DateFooter" With ActiveDocument.Bookmarks .DefaultSorting = wdSortByName .ShowHidden = False End With Selection.TypeText Text:="asd" End Sub

Hey! When I run it I get the same error. ‘Word can’t find the bookmark’. But when I do it by hand via ‘go to bookmark’ it finds it.

I am afraid Xojo can’t help you to fix a MS Word bug. Btw which version of Word ?
As I’ve build quite some VBA macro’s for MS Office in the past, I remember that headers and footers not always behave the same as the document body.

Hello Gentlemen,

Joost, thanks for helping Alexander. My apologies for not reading this post.

It appears that Microsoft Word wanted to make it easier to search for a bookmark after Office 2010. I tried the following command and it works on Xojo 2016 r3 and Office 2016:

word.ActiveDocument.Bookmarks("DateFooter").Select_

Note to Self: Add this to the next Word Book release :slight_smile:

[quote=297226:@Eugene Dakin]Hello Gentlemen,

Joost, thanks for helping Alexander. My apologies for not reading this post.

It appears that Microsoft Word wanted to make it easier to search for a bookmark after Office 2010. I tried the following command and it works on Xojo 2016 r3 and Office 2016:

word.ActiveDocument.Bookmarks("DateFooter").Select_

Note to Self: Add this to the next Word Book release :)[/quote]

Hi Eugene,

I just noticed your post. I will try tomorrow.

Thanks!

[Can’t edit]

Hi Eugene. Works. Thanks for your effort in this. So the

Word.Selection.GoTo_(Office.wdGoToBookmark,nil,nil,"DateFooter") is replaced by the

word.ActiveDocument.Bookmarks("DateFooter").Select_

Sander