Error in macro when using Office 2003

A

Art®

Sometime back I created a Word macro that called up a custom dialog box with
several directory choices. When the user clicked on one of these, it opened
the built-in File Open dialog so the user could click on a file in the
specified directory. The macro worked fine in Office 2000, but when I run it
in Office 2003, it gives me the following error message:

Run-time error '5479': You cannot close Microsoft Office Word because a
dialog box is open. Click OK, switch to Word, and then close the dialog box.

According to Microsoft, Office 2000 VBA macros should work the same in
Office 2003.

The bottom portion of the macro, starting at the "With" statement, works
fine as a stand alone macro, but when used as part of the larger macro in
combination with the custom dialog box will not work in Office 2003.

A portion of the macro is listed below:

Sub art()
doc$ = "c:\Documents and Settings\owner\My documents\"
If OptionButton1.Value = True Then ChangeFileOpenDirectory doc$
If OptionButton2.Value = True Then ChangeFileOpenDirectory doc$ + "Arts"
If OptionButton3.Value = True Then ChangeFileOpenDirectory doc$ + "BJ"

With Dialogs(wdDialogFileOpen)
.Name = "*.*"
.Show
End With
End Sub

I would appreciate any help you could offer. I have tried a variety of work
arounds, including error trapping, but nothing has worked.

Art
 
K

kirstykiwi

Hide your custom dialog box before opening the built-in "Open" dialog box.
i.e. Me.Hide after checking the option buttons.
 
A

Art®

Thanks you for your help. The .hide statement was exactly what I needed. The
macro worked correctly the first time after I put it in!
Thanks for ending my frustration. I still find it curious that the same
macro works in Office 2000 without the .hide statement.

Art
 

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