XL2000: Run-time Error '1004' Saving Workbook as Text

ID: Q199268


The information in this article applies to:
  • Microsoft Excel 2000


SYMPTOMS

When you run a Microsoft 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:

  1. Open the workbook that you are trying to save as text.


  2. Press ALT+F11 to open the Visual Basic Editor.


  3. On the Tools menu, click VBAProject Properties, and then click the Protection tab.


  4. Click to clear the Lock project for viewing check box. Click OK.


  5. 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 this to be a problem in the Microsoft products listed at the beginning of this article.

Additional query words: XL2000

Keywords : kbdta
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbbug


Last Reviewed: October 14, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.