+ Reply to Thread
Results 1 to 3 of 3

error 1004 Method SaveAs of Workbook failed

  1. #1
    Maury Markowitz
    Guest

    error 1004 Method SaveAs of Workbook failed

    I'm trying to save a backup copy of a macro-created workbook as a CSV. The
    workbook has a single sheet. This line fails with a 1004 error:

    oExcelApp.activeworkbook.SaveAs filename:="L:\aTest\Sent\Trades_" &
    Format(date, "yyyy-mm-dd"), FileFormat:=xlCSV, CreateBackup:=False

    Anyone have any ideas? When I try a SaveAs manually I get a dialog -- if
    this is the problem, how can I avoid this?

    Maury

  2. #2
    Tom Ogilvy
    Guest

    Re: error 1004 Method SaveAs of Workbook failed

    good bet you are using Late Binding. As such, the constant xlCSV would have
    a value of zero when you want to pass a value of

    6. So do that explicitly

    oExcelApp.activeworkbook.SaveAs _
    filename:="L:\aTest\Sent\Trades_" & _
    Format(date, "yyyy-mm-dd"), _
    FileFormat:=6, _
    CreateBackup:=False

    --
    Regards,
    Tom Ogilvy

    "Maury Markowitz" <[email protected]> wrote in
    message news:[email protected]...
    > I'm trying to save a backup copy of a macro-created workbook as a CSV. The
    > workbook has a single sheet. This line fails with a 1004 error:
    >
    > oExcelApp.activeworkbook.SaveAs filename:="L:\aTest\Sent\Trades_" &
    > Format(date, "yyyy-mm-dd"), FileFormat:=xlCSV, CreateBackup:=False
    >
    > Anyone have any ideas? When I try a SaveAs manually I get a dialog -- if
    > this is the problem, how can I avoid this?
    >
    > Maury




  3. #3
    Maury Markowitz
    Guest

    Re: error 1004 Method SaveAs of Workbook failed

    Geez Tom, I think I'm up to owing you a bottle of something nice by this
    point. Name yer poison! (seriously)

    Maury


+ 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