Solved

Message box - overwrite file

Posted on 2014-12-16
1
247 Views
Last Modified: 2014-12-16
Hi,

My below sub saves a file

If the file is already there I want a Yes/No message box saying "File already exist, overwrite"

If yes, overwrite, if no exit sub

Thanks




Sub SaveTheFile_BB()

'This code saves the file that has been manipulated with the affix "Manipulated"
'This means, for audit and cross checking purposes, we have the original file and the
'manipulated file


    SuffixDate = Format(Date, "dd mmm")
    FileYear = Year(Date)

    MonthOffset = 0
If Day(Date) = 1 Then MonthOffset = 1
    FileMonth = Month(Date) - MonthOffset
    FileDate = Format(Date, "mmm yy")
    FilePath = "R:\SPM\CAO\FRA\" & FileYear & "\" & FileDate & "\France BB - " & SuffixDate & ".xlsx"

    ActiveWorkbook.SaveAs Filename:=FilePath

    ActiveWorkbook.Close



End Sub
0
Comment
Question by:Seamus2626
1 Comment
 
LVL 32

Accepted Solution

by:
Rob Henson earned 500 total points
ID: 40503037
If the File already exists you should get the standard overwrite warning unless somewehere earlier in the script you have switched off Events and/or Alert Displays.

Before the Save As line include:

Application.DisplayAlerts = True

Thanks
Rob H
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel Formula 4 28
Easy Excel formula needed 4 26
Excel 2010 - Populate a formula in multiple cells 6 24
Auto Adjust Percent rate 5 29
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now