"Open" FileDialog Problems in Word XP

C

Culichi

Greetings--

I'm at an utter loss . . . I've been working on a Word macro that begins
with an "Open File" file dialog box that let's me choose the file I want
to work with. The code works just fine, and it worked alright the first
couple of trials, but suddenly the dialog box stopped recognizing any of
the files in the folders (!!!) Anyone have any idea how this could
happen and how to solve it?

A few other considerations . . . (1) One thing I've done to trouble-
shoot this is change "msoFileDialogOpen" to each of the other three
options (FilePicker, FolderPicker, and SaveAs). All three of these open
a dialog box that has no trouble recognizing the files. (2) In the
"Files of Type:" field at the bottom of the dialog box, these three
other dialog types all say "All Word Documents"--and nothing else--as
the defaults. When the offending "Open" dialog box opens, this field
lists Application and filetype options, and parenthetically includes all
the filetype suffixes for each option. Moreover, it doesn't matter which
of these I select, it still fails to recognize files (ANY files...) in
the folder field/window.

I'm absolutely baffled. None of the code in that first step changed
between when it worked right and when it didn't.

Any help would be greatly appreciated.

Kelley
 
J

Jay Freedman

Hi, Kelley,

Your mention of the FilePicker etc. makes me think you're using the
Common Dialogs control in ComCtrl32.ocx. Don't -- it's flaky. Instead,
just call Word's built-in FileOpen dialog, like this:

Dialogs(wdDialogFileOpen).Show

or, if you just want to grab the name but not actually open the file,
do something like this:

With Dialogs(wdDialogFileOpen)
If .Display Then
MsgBox WordBasic.FilenameInfo$(.Name, 1)
Else
MsgBox "No file selected"
End If
End With

See these two articles for more help:

http://word.mvps.org/FAQs/MacrosVBA/WordBasicCommands.htm
http://word.mvps.org/FAQs/MacrosVBA/WordDlgHelp.htm
 

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