Microsoft KB Archive/143344

{|
 * width="100%"|

MXL: Problems Using the SAVE.AS and SaveAs Macro Functions

 * }

-

The information in this article applies to:


 * Microsoft Excel for Windows, versions 3.0, 4.0, 5.0, 5.0a
 * Microsoft Excel for the Power Macintosh, versions 5.0, 5.0a

-

SYMPTOMS
When you use the SAVE.AS function in a Microsoft Excel 4.0 macro, you may receive the following error message:

Cannot access ' '

where 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 found

The 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.

CAUSE
In 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.

WORKAROUND
To 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 INFORMATION
Both 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.