Greetings,
Not sure as to why my previous thread did not post. I have several macros to either Save or Print (PDF) a worksheet. I would like to insert code to cancel/exit the macro if the user presses the "Cancel" button on the SaveAs or Print dialog box (the computer standard dialog box). Here is a sample code:
Sub Create_new_Workbook()
Dim dirPath, filename As String
Dim varResult As Variant
dirPath = Application.ActiveWorkbook.path
filename1 = Sheet8.Range("AV2")
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Sheet8.Range("BA2").FormulaR1C1 = ""
Call step_1_new_Worksheet 'correct
Dim V
V = Application.GetSaveAsFilename(FileFilter:="excel files (*.xlsm), *.xlsm", Title:="save as", InitialFileName:=dirPath & "\" & filename1)
If V <> False And V <> ActiveWorkbook.FullName Then
ActiveWorkbook.SaveCopyAs V
With Workbooks.Open(V)
Application.DisplayAlerts = False
Call step_2_new_Worksheet
Call step_3_new_Worksheet
Application.DisplayAlerts = True
Call step_4_new_Worksheet
.Close True
End With
End If
Call step_5_new_Worksheet
Sheet8.Range("BB2").FormulaR1C1 = ""
Sheet8.Range("BC2").FormulaR1C1 = ""
Sheet8.Range("BA2").FormulaR1C1 = "Casey"
Sheets("Master_Main").Select
Range("E12").Select
uf_Message_downLoad.Show
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
Bookmarks