View Single Post
  #2  
Old September 5th, 2004, 08:07 AM
John Nurick
external usenet poster
 
Posts: n/a
Default

Hi Joanne,

I can't see anything in your code that would cause this, so the first
thing is to make certain that there isn't a left-over Word locking file.
These can easily get left behind if Word crashes or is forced to close.
If you double-click on the Word document in Windows Explorer, does it
open normally? If not, delete any temporary files in the same folder.
Word usually puts ~ characters in their names; for more information see
http://word.mvps.org or the Microsoft knowledgebase.

One line in your code that I'd expect to cause a problem is
oDoc.Save = True
which should just be
oDoc.Save


On Sat, 04 Sep 2004 22:20:02 GMT, Joanne
wrote:

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


--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.