MXL: Problems Using the SAVE.AS and SaveAs Macro FunctionsLast reviewed: December 1, 1997Article ID: Q143344 |
The information in this article applies to:
SYMPTOMSWhen you use the SAVE.AS function in a Microsoft Excel 4.0 macro, you may receive the following error message:
Cannot access '<file name>'where <file name> is the name of the file you are saving. In Microsoft Excel version 5.0, if you attempt to save a workbook using the SaveAs method in a Microsoft Visual Basic for Applications macro, you may receive the following error message:
Path not foundThe file name may appear correctly in the file's title bar on the screen. However, the directory to which the file is saved will actually contain a file name with random numbers and characters, such as 860FB600. If you make additional attempts to save files by using the Save or SaveAs methods during the current session of Microsoft Excel, you may receive the error message stated above.
CAUSEIn both cases, the behavior occurs if the file name you provide in the SAVE.AS function or the SaveAs method is longer than 31 characters. The Apple Macintosh operating system limits a file name to 31 characters.
WORKAROUNDTo work around this behavior, use a shorter file name when you save your document with the SAVE.AS function or SaveAs method. If you experience this behavior with the SaveAs method, quit and restart Microsoft Excel in order to programmatically save any more files with the Save or SaveAs methods. If you need to save a file before quitting Microsoft Excel, use the Save or SaveAs commands on the File menu.
MORE INFORMATIONBoth the SAVE.AS function and the SaveAs method have arguments to specify a name for the file you are saving. These arguments are document_text and filename, respectively. These macro functions are used to save a worksheet or workbook with a new file name, file type, protection password, or to create a backup file. For both the document_text and filename arguments, you can include a full path and file name. Regardless of the path length, the actual file name you use must be no more than 31 characters long.
REFERENCES"Microsoft Excel Function Reference," version 4.0, page 369 For more information about SAVE.AS, click the Search button in the Microsoft Excel Macro Functions Help file and type:
SAVE.ASFor more information about the SaveAs method, click the Search button in the Microsoft Excel Visual Basic Help file and type:
SaveAs Method |
Additional query words: 3.00 4.00 5.00 5.00a 32
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |