XL97: Run-time Error 1004 When You Save Workbook as Text
Article ID: 198671
Article Last Modified on 2/6/2001
APPLIES TO
- Microsoft Excel 97 Standard Edition
This article was previously published under Q198671
SYMPTOMS
When you run a Visual Basic for Applications macro that saves a workbook as text, you may receive the following error message:
Run-time error '1004':
Method 'SaveAs' of object '_Workbook' failed"
CAUSE
This error message occurs when the following conditions are true:
- The Lock Project for Viewing option is selected in the Visual Basic for Applications project.
-and-
- You run a macro that uses the .SaveAs method and the FileFormat argument is set to xlText
WORKAROUND
To work around this problem, unlock the workbook before running the macro. To do this, follow these steps:
- Open the workbook that you are trying to save as text.
- Press ALT+F11 to open the Visual Basic Editor.
- On the Tools menu, click VBAProject Properties, and then click the Protection tab.
- Click to clear the Lock project for viewing check box. Click OK.
- On the File menu, click Save. Press ALT+Q to return to Excel.
The macro should now run properly and save the workbook as a text file.
STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.
Additional query words: XL97 Run-time error 1004 Method SaveAs of object _Workbook failed
Keywords: kberrmsg kbbug kbdtacode kbpending KB198671