I have a database that amongst other things requires a user to enter data, which after saving it to the database, then takes that same information and puts it into a word document ready for the user to complete the word document. I am attempting to insert the data using bookmrks with the following code.
'Gets word running
Set WordObj = CreateObject("Word.Application")
'makes word visible
WordObj.Visible = True
'makes new document based on the template
WordObj.Documents.Add Template:="G:\JLW Office Templates\Letter with logo.dot", NewTemplate:=False
WordObj.Activate
'insert text at bookmark
WordObj.Selection.Goto what:=wdGoToBookmark, Name:="job"
WordObj.Selection.TypeText [Forms]![correspondence entry form]![jobname]
All goes well until i reach the wdGoToBookmark line. I keep getting the message Runtime error 5101 This bookmark does not exist.
The bookmark definitley does exist in the template. And in the Word Session opened by the code, the document also contains the bookmark.
I cant figure out why the code cant find the bookmark.
Can anyone help?
TIA
Geoff
'Gets word running
Set WordObj = CreateObject("Word.Application")
'makes word visible
WordObj.Visible = True
'makes new document based on the template
WordObj.Documents.Add Template:="G:\JLW Office Templates\Letter with logo.dot", NewTemplate:=False
WordObj.Activate
'insert text at bookmark
WordObj.Selection.Goto what:=wdGoToBookmark, Name:="job"
WordObj.Selection.TypeText [Forms]![correspondence entry form]![jobname]
All goes well until i reach the wdGoToBookmark line. I keep getting the message Runtime error 5101 This bookmark does not exist.
The bookmark definitley does exist in the template. And in the Word Session opened by the code, the document also contains the bookmark.
I cant figure out why the code cant find the bookmark.
Can anyone help?
TIA
Geoff