Dialog Box Error

J

John Finlay

I have a VBA macro that opens a form for input, searches a network folder,
then loops through the Word docs in the folder, modifies them, and prints
them. We have since moved the application to a new PC, and I am having
problems. When the first document in the loop tries to open, I get:

"You cannot close Microsoft Office Word because a dialog box is open. Click
OK, switch to Word, and then close the dialog box."

Here's what I have tried:

1. Searched for the Norton Antivirus dll that causes problems...not found
since we use McAfee.
2. Looked in the Office11 startup folder as well as the user's startup
folder in her profile...both folders are empty.
3. Checked my VBA references...nothing missing.
4. In options, toggled settings for View Windows in Taskbar, allow
background saves, provide feedback with animation, make hidden markup visible
when opening or saving.
5. Set macro security to low.

I cannot see a dialog box open, other than my VBA form. Any suggestions?

TIA,

John
 
J

John Finlay

I'm using Word 2003 on Win XP Pro SP2
Here is a code snippet:
With Application.FileSearch
.NewSearch
.LookIn = mpath
.SearchSubFolders = True
.FileName = "*.doc"
.Execute
ChangeFileOpenDirectory mpath
For i = 1 To .FoundFiles.Count
Application.Documents.Open .FoundFiles(i)
...
The error stops on Application.Documents.Open .FoundFiles(i)
Funny that the error message starts "You cannot close ..." when I'm trying
to open a document. Also, when I end the code the new document is open.
 
D

Doug Robbins - Word MVP

The following adaption of your code works fine for me:

Dim mpath As String
mpath = "c:\Documents"
With Application.FileSearch
.NewSearch
.LookIn = mpath
.SearchSubFolders = True
.FileName = "*.doc"
.Execute
ChangeFileOpenDirectory mpath
For i = 1 To 2 '.FoundFiles.Count - I did not want to open all of
the files
Application.Documents.Open .FoundFiles(i)
Next i
End With
End Sub

Is there some code in one of the documents that is being opened that could
be causing the problem?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
J

John Finlay

Doug -

Thanks for the reply. I checked and the only macros are the ones I wrote
that are stored in normal.dot in this user's profile. There is no autoexec
macro...but thanks anyway because I didn't check the other documents prior to
the initial post.

I may post this in forums other than programming since the code worked prior
to moving it to a new pc... it could be an install or general settings type
of issue.

Thanks,

John
 

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