View Single Post
  #1  
Old September 4th, 2004, 11:20 PM
Joanne
external usenet poster
 
Posts: n/a
Default auto filling bookmarks in word2000

I am trying to automate the filling in of bookmarks in a word document
with information in my access table.
This is the coding I am using, but something is wrong with it. What
happens is I get a dialog box telling me I can only open in read only
mode as the file is "in use by another user".
SInce it opens only in 'read only' mode, my bookmarks are not filled
in and I am not sure if that portion of the function is working
either.

Could someone help me find the error of my ways please?
I am using MSOffice 2000 on a winxp machine.

Function SetBookmark()
Dim oWrd As Word.Application
Dim oDoc As Object

' Start Microsoft Word and open the document.
Set oWrd = CreateObject("Word.Application")
oWrd.Documents.Open "C:\NMWorkPackage\DirectDepAuthorization.doc"

'Pass the field info to the word bookmark
With oWrd.ActiveDocument.Bookmarks
.Item("SSN").Range.Text = frmEmpContInfo.SSN
End With

'Printout the doc with the bookmarks in place
If Not oDoc Is Nothing Then
oDoc.PrintOut
oDoc.Save = True
oDoc.Close
End If

oWrd.Quit
End Function

Thanks for your time and help. It is surely appreciated