At present I use A03 and Word03 and I would like to be able to fill in predetermined fields in Word from my A03 db. I do not want to use mail merge.
I want to use Late Binding for compatibility across versions of Word. I tried inserting bookmarks in the Word document, but I do not seem to be able to reference the bookmark from A03 though VBA. The code below opens an existing Word file "abc.doc" and writes text.
BTW is bookmarks the way to go? If yes, how do I refernce a bookmark say "txtBookmark" and assign to it the value say "George".
Thanks
I want to use Late Binding for compatibility across versions of Word. I tried inserting bookmarks in the Word document, but I do not seem to be able to reference the bookmark from A03 though VBA. The code below opens an existing Word file "abc.doc" and writes text.
BTW is bookmarks the way to go? If yes, how do I refernce a bookmark say "txtBookmark" and assign to it the value say "George".
Thanks
Code:
Dim objWord As Object
Dim doc As Object
Dim bolOpenedWord As Boolean
On Error Resume Next
Dim blnDum As Boolean
blnDum = fIsAppRunning("word", True)
If blnDum = True Then
Set objWord = GetObject(, "Word.Application")
Else
Set objWord = CreateObject("Word.Application")
End If
objWord.Documents.Open "C:\junk\abc.doc"
bolOpenedWord = True
objWord.Visible = True
On Error GoTo 0
objWord.Activate
Set doc = objWord.Documents.Add
'Insert Text
objWord.Selection.TypeText "This is a test" & vbCrLf
'Insert Paragraph
objWord.Selection.TypeParagraph
'Insert More text and Paragraphs
objWord.Selection.TypeText "More text inserted"
objWord.Activate
On Error Resume Next
doc.Save
On Error GoTo 0
doc.Close False
Set doc = Nothing
If bolOpenedWord = True Then
objWord.Quit
End If
Set objWord = Nothing