Jason Barnes
New Member
- Joined
- Jan 15, 2015
- Messages
- 46
I need to save sheet as pdf.
Have tried numerous codes from examples and continue to fail.
Getting Runtime Error 1004;
Document not saved. The document may be open, or an error may have been encountered when saving.
Have tried numerous codes from examples and continue to fail.
Getting Runtime Error 1004;
Document not saved. The document may be open, or an error may have been encountered when saving.
Code:
Sub SaveAsPDFExcel()
Dim fName As String
Dim sLoc As String 'location
sLoc = "C:\Users\Jason Barnes\Desktop\Denbury\"
' Select sheet to export into PDF file
Sheets("MAIN").Select
With ActiveSheet
fName = .Range("BC3").Value
'Save as xlsm
ActiveWorkbook.SaveAs Filename:=sLoc & fName, FileFormat:=xlOpenXMLWorkbookMacroEnabled
' Export to the PDF
.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
sLoc & fName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
End With
End Sub