I simply want to unhide a sheet that contains a report then export that sheet as a pdf then hide it once again and go back to another sheet, however when running this code I receive a "RunTime Error 1004 Application-defined or object-defined error"
Sub Print_To_PDF()
Sheets("Report").Visible = True
Sheets("Report").Select
Dim pdfname As String
pdfname = Range("A1").Value
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=pdfname, Quality:=xlQualityStandard, _
IncludeDocProperties:=False, IgnorePrintAreas:=False, OpenAfterPublish:=True
Sheets("Report").Visible = False
Sheets("Summary").Select
End Sub
It works sometimes and even on other computers not sure why I am getting this error. Can someone please help.