XL2000: The GetSaveAsFilename Method Returns an Extra Character (213751)
The information in this article applies to:
This article was previously published under Q213751 SYMPTOMS
When you use the GetSaveAsFilename or GetOpenFilename methods in a Microsoft Visual Basic for Applications macro, Microsoft Excel may add a period (.) to the end of the string that is returned. When the period is appended, you may receive unexpected results when you use the string as the file name argument for the SaveAs or Open methods.
CAUSE
This behavior can occur if you do not add a file name extension to the file
name that you type in the dialog box provided by GetSaveAsFilename or GetOpenFilename. For example, if you type Test, GetSaveAsFilename returns "Test." (without the quotation marks). If the macro passes this string to the SaveAs method, the macro does not add a file name extension to the file name when the file is saved. If you type a file name with a file name extension, such as Test.xls, a period is not added to the end of the string that is returned.
WORKAROUND
To work around this issue, when you use the GetSaveAsFilename or GetOpenFilename method, determine whether there is a period at the end of the string that is returned. If the rightmost character is a period, strip it from the string before you pass it to the SaveAs method.
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. REFERENCESFor more information about the GetSaveAsFilename method, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type getsaveasfilename method example in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
For more information about the GetOpenFilename method, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type getopenfilename method in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
| Modification Type: | Minor | Last Reviewed: | 10/11/2006 |
|---|
| Keywords: | kbbug kbdtacode kbpending kbProgramming KB213751 |
|---|
|