Word VBA code unable to find Bookmark
I am not a programmer, but I'm trying to help a friend with document automation.
In a Word letter, I have constructed a Dialogue Box and the VBA code uses Bookmarks to go to specific areas and populate the letter with data entered in the Dialogue Box.
This works fine on the first page. The problem is on the second page, where a Page Break is inserted by VBA code and the Header contains two Bookmarks.
The plan is to go to the first Bookmark and insert text from the Dialogue Box, but the VBA code displays an error that it can't find the Bookmark.
I can find that Bookmark manually in that Word document fine, so I don't know what I'm doing wrong.
The code is:
Selection.GoTo What:=wdGoToBookmark, Name:="Name1"
Selection.TypeText Text:=txtName.Text
I would be grateful for your help.
Regards
Useful
|