+ Reply to Thread
Results 1 to 3 of 3

Overwrite existing workbook without prompting

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-13-2006
    Location
    London
    Posts
    102

    Question Overwrite existing workbook without prompting

    My macro saves a workbook and overwrites an existing one. How can I stop the macro from asking if I want to replace the existing one?

    Application.DisplayAlerts = false does not help, as the default answer is 'no' and doesn't overwrite the workbook.

    What can I do?

    Thanks.

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    Try so:

    Sub Macro1()
       ExistFile = Dir(FileToSave)
       If ExistFile <> "" Then
          Kill FileToSave
       End If
    
       'Then save file    
       ThisWorkbook.SaveAs (FileToSave)
    End Sub
    Regards,
    Antonio

  3. #3
    Forum Contributor
    Join Date
    04-13-2006
    Location
    London
    Posts
    102

    Talking

    Thanks Antonio, that's solved it perfectly!

+ 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