+ Reply to Thread
Results 1 to 3 of 3

Save as Overwrite prompt

  1. #1
    Steph
    Guest

    Save as Overwrite prompt

    Sub Save_Book()
    Application.DisplayAlerts = False
    ActiveWorkbook.SaveAs Filename:=filepath & "VA05.xls"
    Application.DisplayAlerts = True
    End Sub

    I want to save a file and automatically overwrite the existing file. I have
    done this a thousand times, and it works fine. But now I am exporting a
    report from an ERP system into Excel. When I run this code against the
    resulting excel file, I get an error Method 'Display Alerts' of object
    'Application' failed. Is there another way of Saving a file without being
    prompted to overwrite or not? (I want the default to be Yes overwrite).
    Thanks!



  2. #2
    Forum Contributor
    Join Date
    11-16-2004
    Posts
    282
    Steph,

    Try this:
    Please Login or Register  to view this content.
    Hope this helps!
    theDude

  3. #3
    Dave Peterson
    Guest

    Re: Save as Overwrite prompt

    Maybe you could just delete the file (or at least try to):

    on error resume next
    kill filepath & "VA05.xls"
    on error goto 0

    activeworkbook.saveas filename:=filepath & "VA05.xls"

    ===
    But I think I'd try to find out why that .displayalerts is breaking. I don't
    recall ever seeing it break.

    Steph wrote:
    >
    > Sub Save_Book()
    > Application.DisplayAlerts = False
    > ActiveWorkbook.SaveAs Filename:=filepath & "VA05.xls"
    > Application.DisplayAlerts = True
    > End Sub
    >
    > I want to save a file and automatically overwrite the existing file. I have
    > done this a thousand times, and it works fine. But now I am exporting a
    > report from an ERP system into Excel. When I run this code against the
    > resulting excel file, I get an error Method 'Display Alerts' of object
    > 'Application' failed. Is there another way of Saving a file without being
    > prompted to overwrite or not? (I want the default to be Yes overwrite).
    > Thanks!


    --

    Dave Peterson

+ 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