Hi everyone
Hope you can help.
I am using a button to run the below code which prints specific data to a PDF, though first it checks to see if cell M21 is blank. If it is then it prompts the user to warn them if they want to proceed or cancel. If they proceed or if cell M21 is NOT blank then the user is greeted by a Msg box saying 'Your Quote Has Been Generated!'
The problem is, if you click cancel at any point or do not print to PDF then it still says 'Your Quote Has Been Generated!'.
Please can someone help amend my code so that it says 'Your Quote Has Been Generated!' ONLY if you save the PDF? Otherwise present the user with 'Quote Cancelled!' if you click on cancel OR click cancel while being promoted to save the PDF? I can't seem to get the code right
Thank you so much!
Hope you can help.
I am using a button to run the below code which prints specific data to a PDF, though first it checks to see if cell M21 is blank. If it is then it prompts the user to warn them if they want to proceed or cancel. If they proceed or if cell M21 is NOT blank then the user is greeted by a Msg box saying 'Your Quote Has Been Generated!'
The problem is, if you click cancel at any point or do not print to PDF then it still says 'Your Quote Has Been Generated!'.
Please can someone help amend my code so that it says 'Your Quote Has Been Generated!' ONLY if you save the PDF? Otherwise present the user with 'Quote Cancelled!' if you click on cancel OR click cancel while being promoted to save the PDF? I can't seem to get the code right
Thank you so much!
Code:
Sub NewQuoteGenerate()
Dim sourceSheet As Worksheet
Set sourceSheet = ActiveSheet
Application.ScreenUpdating = False
Dim response As VbMsgBoxResult
With Worksheets("Dashboard")
If Len(.Range("M21").Value) = 0 Then
response = MsgBox("You have not added any caveats or assumptions!" & Chr(10) & Chr(10) & "Are you sure you want to continue?", 36, "Caveats & Assumptions")
If response = vbNo Then .Activate: .Range("M21").Select: Exit Sub
End If
End With
Sheets("Quotation").PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False
ChDir "Z:\General\Folderlocation\"
Sheets("Quotation").ExportAsFixedFormat Type:=xlTypePDF, Filename:=ActiveSheet.Name _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
MsgBox "Your quote has been generated!", vbInformation
Application.ScreenUpdating = True
Call sourceSheet.Activate
End Sub
Last edited: