Close Word Document - ive tried for hours!

shamas21

Registered User.
Local time
Today, 15:33
Joined
May 27, 2008
Messages
162
Hi All

Ive been trying for hours to close a word document i have.

I open it from Access VBA with the following code

Code:
Dim MSWord As New Word.Application
Set MSWord = New Word.Application
 
MSWord.Documents.Open FileName:="V:\Confirmation Of Instructions - Capital Visas"
 
MSWord.Selection.TypeText Text:="Line 1"
 
MSWord.Documents.Close
Set MSWord = Nothing

But it doesnt completely close the Word document; instead it leaves a temporary file called '~$nfirmation Of Instructions - Capital Visas' which indicates to me that the document isnt closed. Also when i try to view the original document it says i can view it read only.

Can someone please help me on how to completely close and Save the document.

Thanks
 
Check the VBA Help for CreateObject Function.

There appears to be a:

Object.Application.Quit

then

Set Object = Nothing

Where Object = MSWord

i.e:

MSWord.Application.Quit
Set MSWord = Nothing
 
Check the VBA Help for CreateObject Function.

There appears to be a:

Object.Application.Quit

then

Set Object = Nothing

Where Object = MSWord

i.e:

MSWord.Application.Quit
Set MSWord = Nothing
very nice, thanks:)
 

Users who are viewing this thread

Back
Top Bottom