Solved

Message box - overwrite file

Posted on 2014-12-16
1
264 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 33

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

738 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