ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,226
- Office Version
- 2007
- Platform
- Windows
I am using the following code supplied below.
This issue i have is that if the code is run & there is no value in cell G13 then i see a Run Time Error Document not saved.
I added the additional code as shown in RED but i after clicking OK to the message box i get the same error.
How can i stop the code from continuing once OK has been clicked so the error isnt shown
This issue i have is that if the code is run & there is no value in cell G13 then i see a Run Time Error Document not saved.
I added the additional code as shown in RED but i after clicking OK to the message box i get the same error.
How can i stop the code from continuing once OK has been clicked so the error isnt shown
Rich (BB code):
Private Sub Generate_Pdf_Click()
Dim sPath As String, strFileName As String
strFileName = "C:\Users\Ian\Desktop\REMOTES ETC\DR\DR SCREEN SHOT PDF\" & Range("G13").Value & ".pdf"
If Dir(strFileName) <> vbNullString Then
MsgBox "GENERATED PDF REQUEST" & vbNewLine & vbNewLine & Range("G13").Value & vbNewLine & vbNewLine & "ALLREADY EXISTS", vbCritical + vbOKOnly, "GENERATE PDF FILE MESSAGE"
Exit Sub
End If
With ActiveSheet
If Range("G13") = "" Then
MsgBox "NO NAME SELECTED IN THE CUSTOMER DETAILS SECTION", vbCritical, "NO CUSTOMER SELECTED MESSAGE"
End If
.ExportAsFixedFormat Type:=xlTypePDF, FileName:=strFileName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False
MsgBox "PDF HAS NOW BEEN GENERATED", vbInformation + vbOKOnly, "GENERATE PDF FILE MESSAGE"
End With
sPath = "C:\Users\Ian\Desktop\REMOTES ETC\DR\DR SCREEN SHOT PDF\"
strFileName = sPath & Range("G13").Value & ".pdf"
If Dir(strFileName) <> vbNullString Then
ActiveWorkbook.FollowHyperlink strFileName
End If
InvoiceClearSheetQuestion.Show
End Sub