Using Access VBA creates Word document but unable to close Word

jbotts

Registered User.
Local time
Today, 00:42
Joined
Jun 8, 2009
Messages
22
Using Microsoft Office 2007, and Windows XP. In Access 2007 a Word document is created, text is added, and Word closed with VBA. Then unable to open the document because it is 'locked by user'.

***********Code*********************
Dim wo As Word.Application
Dim path As String

Set wo = CreateObject("Word.Application")
wo.Documents.Add
wo.ActiveDocument.SaveAs FileName:=path

'Text added to the document

wo.ActiveDocument.Save
wo.ActiveDocument.Close False
wo.Quit
Set wo = Nothing
**********End of Code******************

The code is successful in creating the document and when looking in the directory, the file is there but with ~owner's file. When attempting to open the file with VBA, the message states the file is locked by the user who created the file.
progress.gif
 
The issue may be in the code that was left out for:

Code:
'Text added to the document


I would look for issues with Object reference that could cause a second instance of Word to get created.

If you can't figure it out then I would recommend posting all the actual VBA code used in the routine.
 

Users who are viewing this thread

Back
Top Bottom