+ Reply to Thread
Results 1 to 6 of 6

Method 'SaveAs' failure

  1. #1
    Registered User
    Join Date
    08-16-2007
    Posts
    4

    Method 'SaveAs' failure

    I have an .xls with multiple worksheets. I have VB script attempting to save one of the worksheets to a new .xls file. When this is run, I get a "Run-time error '1004': Method 'SaveAs' of object '_Workbook' failed" error. My script outputs data to Sheet1. I can save Sheet1 to the new .xls file without problem. But if I add a new sheet, say, Sheet2, and try to save it to the new file, then I receive the above error. I do not receive this error if I save to a .csv or .txt file. The line that causes the error is as follows:

    Please Login or Register  to view this content.
    Any thoughts would be appreciated.

  2. #2
    Registered User
    Join Date
    08-16-2007
    Posts
    4
    Further investigation has shown that my problem occurs also when saving as a .csv, which is contrary to my initial post.

    Again, any thoughts on this or similiar problems would be appreciated.

  3. #3
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    for csv file have you tried

    Please Login or Register  to view this content.
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  4. #4
    Registered User
    Join Date
    08-16-2007
    Posts
    4
    That is exactly how it tries to save for .csv.

  5. #5
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    I went back & re-read both your messages & I realized I missed an inportant part in the 1st message

    You can only have 1 sheet in a book to save the file as a csv file

  6. #6
    Registered User
    Join Date
    08-16-2007
    Posts
    4
    For all formats, I am taking the data from a single sheet and saving that to a new file. That way I can save to .csv or .xls. Well, I could if not for the SaveAs function failing on me.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1