PDA

View Full Version : Finding and Closing a hidden Open Word Doc



Laury Burr
06-08-2009, 08:23 AM
The application I'm working on (an Access Project) is required to create a Word document, create its filename and path programmatically, and save it. All while hidden (ie Visible = False).

Occasionally a user gets the error message "Word cannot give a document the same name as an open document." But of course as it's not visible the user doesn't believe the message - and even if they did they're powerless to close it.

So what I'm seeking is how to locate the open but hidden file with the offending filename so it can be programmatically closed before the newly created copy can be saved without the error message.

Any thoughts?

Laury "frustrated of Croydon" Burr.

lucas
06-08-2009, 02:14 PM
If you create an instance of word you need to close it at the end of your code. If you create it similar to this if you use a word template:
Set oWord = GetObject(Class:="Word.Application")
use the following at the end of your code.
oWord.Quit
or if you use something like:
Set Appword = CreateObject("Word.Application")
use:
Appword.ActiveDocument.SaveAs Filename:=MyFol & sh.Name & ".doc"
'Close document
Appword.ActiveDocument.Close