Force yes for save over and save as macro free workbook

Duraholiday picture Duraholiday · Aug 12, 2015 · Viewed 9k times · Source

The macro I made saves a template workbook as two separate files. One is saved per test (Location1,2,3, or 4) then is used in another macro to use the data from each test. The Second is a raw data file kept for back up. Now the issue is every time I run the test per location and run this macro it ask me if I want to save over the previous test. How can I tell it to say yes with out asking. Same for the do i want to save this workbook as a macro free workbook. What do i have to put in my code and where should i put it? Any helps is much appreciated. Thanks

Solved Code:

Sub Auto_Open()

   With Range("A30")
   .Value = Time
   .NumberFormat = "h-mm-ss AM/PM"
   End With

    Dim FileName    As String
    Dim FilePath    As String
    Dim FileDate    As String

    MyNote = "Is Cell 'B27' Overview Information" & SavePath & " Location1,2,3,or 4?"

    Answer = MsgBox(MyNote, vbQuestion + vbYesNo)

    If Answer = vbYes Then

        FilePath = "C:\Users\aholiday\Desktop\FRF_Data_Macro_Insert_Test"
        FileName = Sheets("Data").Range("B27").Text

        Application.DisplayAlerts = False

        ThisWorkbook.SaveAs FileName:=FilePath & "\" & FileName

        Dim FileCopyName    As String
        Dim FileCopyPath    As String
        Dim FileTime        As String

        FilePath = "C:\Users\aholiday\Desktop\Backup"
        FileName = Sheets("Data").Range("B27").Text
        FileTime = Sheets("Data").Range("A30").Text


        ThisWorkbook.SaveAs FileName:=FilePath & "\" & FileName & FileTime & ".xlsx", FileFormat:=xlOpenXMLWorkbook

        MsgBox "File was saved!"
        MsgBox "Ready for Next Test, Please Exit."

        Application.DisplayAlerts = True

    Else
       MsgBox "File was not saved, Please Use Location_1,2,3or,4 Durring SIG ATM Test"
    End If

End Sub

Answer

Darren Bartrup-Cook picture Darren Bartrup-Cook · Aug 12, 2015

Add Application.DisplayAlerts = False before you try and save. Remember to turn in back to True after you've saved.