ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,226
- Office Version
- 2007
- Platform
- Windows
Morning,
I have a code which generates a pdf file from my sheet.
For unknown reason now when i run the code it generates an error and when i debug the text in red below is shown.
Can you advise please.
I have a code which generates a pdf file from my sheet.
For unknown reason now when i run the code it generates an error and when i debug the text in red below is shown.
Can you advise please.
Rich (BB code):
Private Sub Generate_Pdf_Click()
Dim 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 "INVOICE " & Range("G13").Value & " WAS NOT SAVED AS IT ALLREADY EXISTS", vbCritical + vbOKOnly, "GENERATE PDF FILE MESSAGE"
Exit Sub
End If
With ActiveSheet
.PageSetup.PrintArea = "$G$3:$O$61"
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=strFileName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False
pdf = MsgBox("INVOICE " & " WAS SAVED SUCCESSFULLY" & vbNewLine & vbNewLine & "DO YOU WISH TO NOW PRINT IT ?", vbExclamation + vbYesNo, "GENERATE PDF FILE MESSAGE")
If pdf = vbYes Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Else
ActiveWorkbook.Save
End If
End With
End Sub