ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   GetOpenFilename in Windows Excel 97 bug? (https://www.excelbanter.com/excel-programming/393414-getopenfilename-windows-excel-97-bug.html)

TomCee

GetOpenFilename in Windows Excel 97 bug?
 
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


Dave Peterson

GetOpenFilename in Windows Excel 97 bug?
 
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.


tomcee wrote:

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


--

Dave Peterson


All times are GMT +1. The time now is 12:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com