The information in this article applies to:
SYMPTOMSThe Visual Basic for Applications GetOpenFilename method works differently in Microsoft Excel for Windows 95 and later than in Microsoft Excel version 5.0. Also, the Help file entry on GetOpenFilename in Microsoft Excel for Windows 95, version 7.0 and Microsoft Excel 97, is not complete on how the FileFilter argument affects the method. CAUSE
The FileFilter argument for the GetOpenFilename method contains two parts.
In Microsoft Excel, version 5.0, the first part, which is before the comma,
appears in the "List Files of Type:" field in the File Open dialog box. The
second filter, which is after the comma, appears in the File Name field of
the dialog box and is the part that actually affects what files are shown.
If you leave out the second part, the function shows all files. The first
part has no effect on what files are shown. It can be anything. Therefore,
you must make sure the two parts match, because you could have a filter in
the "List Files of Type:" field that does not match the list of files
shown.
WORKAROUND
For simplification, in Microsoft Excel for Windows 95 and Microsoft Excel 97,
you can use the first filter as if it were the only filter. However, you must
include the comma to avoid a syntax error. Also, you should avoid characters
before a wildcard in the file name.
fileFilter:="Text Files (*.txt)," MORE INFORMATIONThe examples below depict the differences between the two versions when running variations of GetOpenFilename. Each example contains a macro that can either be run in Microsoft Excel 5.0, Microsoft Excel for Windows 95, or in Microsoft Excel 97. The comments before each macro describe the results you receive in each of the three versions. Visual Basic Code ExamplesMicrosoft provides examples of Visual Basic for Applications procedures for illustration only, without warranty either expressed or implied, including, but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. The Visual Basic procedures in this article are provided 'as is' and Microsoft does not guarantee that they can be used in all situations. While Microsoft support professionals can help explain the functionality of a particular macro, they will not modify these examples to provide added functionality, nor will they help you construct macros to meet your specific needs. If you have limited programming experience, you may want to consult one of the Microsoft Solution Providers. Solution Providers offer a wide range of fee-based services, including creating custom macros. For more information about Microsoft Solution Providers, call Microsoft Customer Information Service at (800) 426-9400. To illustrate, the following are a few examples of the various differences between the two versions.Example 1Microsoft Excel version 5.0 shows "Text Files (test*.*)" in the "List Files of Type" field and only lists files beginning with "test."Difference: Microsoft Excel for Windows 95 and Microsoft Excel 97 show nothing in the "Files of Type" field and lists all files.
Example 2Microsoft Excel version 5.0 shows "Text Files (*.txt)" in the "List Files of Type:" field and only lists files ending in "xls".Difference: Microsoft Excel for Windows 95 and Microsoft Excel 97 show "Text Files (*.txt)" in the "Files of Type" field and displays files ending in ".txt".
Example 3Microsoft Excel version 5.0 shows "Text Files (*.txt)" in the "List Files of Type:" field and lists all files.Difference: Microsoft Excel for Windows 95 and Microsoft Excel 97 show "Text Files (*.txt)" in the "Files of Type" field and displays files ending in ".txt".
Example 4Microsoft Excel version 5.0 shows "Text Files (bob*.txt)" in the "List Files of Type:" field and displays files beginning with "bob" and ending with "txt".Difference: Microsoft Excel for Windows 95 and Microsoft Excel 97 show nothing in the "Files of Type" field and lists all files.
Example 5Microsoft Excel version 5.0 shows "Text Files (*.tx*)" in the "List Files of Type:" field and displays files with ".tx" as part of the extension.Difference: Microsoft Excel for Windows 95 and Microsoft Excel 97 show "Text Files (*.tx*)" in the "Files of Type" field and displays files with ".tx" as part of the extension.
Example 6/> Microsoft Excel version 5.0 shows nothing in the "List Files of Type:" field and displays files ending in ".txt".Difference: Microsoft Excel for Windows 95 and Microsoft Excel 97 show "(*.txt)" in the "Files of Type" field and displays files ending in ".txt".
STATUSREFERENCESMicrosoft Excel 97For more information about GetOpenFilename, click the Office Assistant, type GetOpenFilename, click Search, and then click to view "GetOpenFilename Method."NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If Microsoft Excel Visual Basic for Applications Help is not installed on your computer, please see the following article in the Microsoft Knowledge Base: Q120802 Office: How to Add/Remove a Single Office Program or Component Microsoft Excel for Windows 95For more information about GetOpenFilename, in Microsoft Excel for Windows 95, click Answer Wizard on the Help menu and type:GetOpenFilename Additional query words: 5.00c 7.00a XL97 8.00
Keywords : |
Last Reviewed: November 9, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |