none
Cancel "Save As" help RRS feed

  • Question

  • Hello -

    This one may be a little easier than my last post...I have some code below that works well...however, I would like to an additional process if the user selects cancel in the the Save As dialog. Just not sure how to go about adding the "If canceled" part (highlighted green area). Maybe someone here can assist? There is probably even a better way of doing this, but this works well without the green highlighted area. Looking to add the green highlighted area to the equation somehow. Any suggestions will be much appreciated. Thanks in advance for your time.

    Here is what I have:

    Public Sub Save_File()

           

    Application.ScreenUpdating = False

     

    Call Number_Advance

     

    ‘Brings up Save as Dialog and inserts file name

    Application.Dialogs(xlDialogSaveAs).Show "TCWbk_" & ThisWorkbook.Sheets("QC").Range("I3") & "_" & ThisWorkbook.Sheets("QC").Range("J8") & "_" & ThisWorkbook.Sheets("QC").Range("D5") & "_Unit" & ThisWorkbook.Sheets("QC").Range("D6") & "_" & ThisWorkbook.Sheets("QC").Range("D4") & "_" & "Effective Date_" & Format(ThisWorkbook.Sheets("QC").Range("D7"), "mmddyyyy") & ".xlsm"

      

     'If above “save as” is canceled then

            Call Reverse_Number_Advance

     

     

    End Sub

    Thursday, August 30, 2018 4:23 PM

Answers

  • I Found it! Through some additional research I was able to put the below together that works as needed. Thanks to those who have spent time on this. Your time is much appreciated. If  anyone has any other ideas feel free to share. Thanks again to all!

    Here is my final solution:

    Public Sub Save_File()

     

        Dim UserResponse As Boolean

           

        Application.ScreenUpdating = False

        Application.EnableEvents = False

     

    Call Number_Advance

     

    UserResponse = Application.Dialogs(xlDialogSaveAs).Show("CAR_" & ThisWorkbook.Sheets("CAR").Range("N1") & " - " & ThisWorkbook.Sheets("CAR").Range("C3")  _ & " - " & ThisWorkbook.Sheets("CAR").Range("I3"), 52)

        If UserResponse = False Then

            MsgBox "Save Canceled"

            Call Reverse_Number_Advance

            End

        Else

            MsgBox "File Saved"

        End If   

        Application.EnableEvents = True

           

    End Sub

    • Marked as answer by rstreets2 Thursday, August 30, 2018 11:20 PM
    Thursday, August 30, 2018 11:20 PM