GetOpenFilename in Windows Excel 97 bug?

T

tomcee

The getopenfilename function in Excel 97 says that:

Quoting the help system:
fileToOpen = Application.GetOpenFilename("What Files (*.txt), *.txt")
In Windows, this string consists of pairs of file filter strings
followed by the MS-DOS wildcard file filter specification, with each
part and each pair separated by commas. Each separate pair is listed
in the Files of type drop-down list box.

However, I've found that the filter is actually in the first part of
the string. The (*.txt) immediately after the 'What Files' is what is
actually used as the filter and the second *.txt does not seem to do
anything at all! That is, if I change this to:
fileToOpen = Application.GetOpenFilename("What Files (*.*), *.txt")
I get all files listed; - the *.txt seems to do nothing.

Is there something in this function that I'm missing?

Thanks in advance,
Tomcee
 
D

Dave Peterson

I don't think you're missing anything, but...

It seems to me that it would be best to just specify what you want exactly once:

Dim WkbkName As Variant

WkbkName = Application.GetOpenFilename(filefilter:="Excel files, *.xls")

If WkbkName = False Then
Exit Sub 'user hit cancel
End If

Then the problem goes away.
 

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