Help with Open dialog please

A

Alan

In a follow up to my earlier post re the possibility of
setting multiple file types (ie *.doc + *.rtf) in the
oopen file dialog I have tried to get around this with a
user form that offers 2 option boxes for DOC or RTF and a
GO button to load the dialog.

What I have for the GO button code is:

Private Sub btnGo_Click()
Dim sName As String
With Me
.Hide
If .optRTF.Value Then
sName = "*.rtf"
Else
sName = "*.doc"
End If
With Dialogs(wdDialogFileOpen)
.Name = sName
.Show
End With
End With
End Sub

but despite the fact that the sName variable and .Name
get set as expected the dialog box when shown only offers
the last file type set using Open in the normal way rather
than .rtf or .doc as set in the code above.

Can anyone suggest why?
 
K

Klaus Linke

Hi Alan,

Works fine for me (Word2000).
"*.doc" / "*.rtf" doesn't appear in the name field (probably because both
are known file types), but only files of the respective type are displayed.

Are you using Word2002/2003? The support for the built-in dialogs has
become worse and worse with each new version, and I wouldn't be surprised
at a new bug.

Regards,
Klaus
 
A

Alan

Klaus
re >Are you using Word2002/2003?
I am using Word97 at present.

Interestingly it will work to change to RTF the first time
it is run, but if run again steadfastly refuses to change
from RTF to DOC.

I am being lazy really. I generally use DOC, but have RTF
export files from other software that I want to open and
carry out tasks.

All I really wanted to do was to set the open file type to
DOC or RTF by default (and not with ANY FILES) but it
seems you can only have one or the other. My get around
was to have this little userform to select which type.

So it really all comes from me not wanting to change the
file type from the open dialog that comes up in the usual
way and defaults to the last file type. Stupid really, but
hey!!?
 
K

Klaus Linke

Hi Alan,

Played around some more, but both "*.doc;*.rtf" to show files of both kinds
and "*.rtf" / "*.doc" to show either kind work nicely here (Word2000).

Especially with the latter I can't imagine a bug in Word97, since this
would be well known.

You might try an ".Update" before the ".Display"/".Show".

Or you might try if the code works if you don't run it from the user form.

Good luck!
Klaus
 

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