This File is in use by another Application or User (Normal.dot) in Word 2003

B

Brad Marshall

I have read many, many posting on this subject but none come close to my
scenario, which is:

1) I have this code snuipped from an Access 2003 application that creates
documents mased on templates and inserts values from an Access table:

'Start of Code Snippet.
.... (some code)

Set objWord = New Word.Application
With objWord
' open a new templat instance.
.Documents.Add Template:=(strDocPath)
' save the document in the default dir.
.ActiveDocument.SaveAs FileName:=stNewDocName,
FileFormat:=wdFormatDocument
.Documents(stNewDocName).Activate
End With

.... (some code that sets the bookmarks in the document(s) to appropriate
values

With objWord
' close the document and save the change.
.Documents(stNewDocName).Close SaveChanges:=wdSaveChanges
' quit word
.Quit
End With

End of code snippet

Under Windows 2000 and Office XP this worked fine, but under Windows 2003 &
Office 2003 the .Close statement generates the "This file is in use by
another application or user" message citing Normal.Dot. I am stumped. Any
ideas?

Thanks, Brad Marshall
 
S

Steve Lang

Hi Brad,

It sounds as if you have a hidden instance of Word running.
Before you run your code in Access:
Do a Ctrl-Alt-Del and click on the task manager button. When that appears,
click Processes and look for WinWord.exe as an image name. If there is one,
you will then have to determine which app has started the instance. It could
be any number of applications.

As a side note, I personally would add Set objWord = nothing at the end of
the code. Word is notoriously bad about cleaning up object variables if you
don't explicitly de-allocate them. I don't know if that is the situation
with Access, but it probably wouldn't hurt.

HTH and have a great day!

Steve
 
B

Brad Marshall

Hmmm, no joy, Steve - no hidden instance. And thanks for the Set objWord =
Nothing. It's there, but I didn't include it in the snippet - but one can't
be reminded of this detail too many times. SO - I'm still looking for the
answer!

Brad Marshall
 
S

Steve Lang

Hi Brad,

Next thought:
Perhaps the document you created - for whatever reason - is trying to update
its source template, in this case, Normal. Try explicitly stating that the
template is not dirty by doing this:

With objWord

Steve
 
B

Brad Marshall

Success!...although I got an error message saying that this command isn't
available because no files are open, so I extrapolated on your thoughts and
put the line you suggested here:

Set objWord = New Word.Application
With objWord
' open a new templat instance.
.Documents.Add Template:=(strDocPath)
' save the document in the default dir.
activedocument.attachedtemplate.saved = true '<<<<<<<<<<<<<
.ActiveDocument.SaveAs FileName:=stNewDocName,
FileFormat:=wdFormatDocument
.Documents(stNewDocName).Activate
End With

Thank you, Steve.

Best regards, Brad Marshall
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top