Billy Hill
Board Regular
- Joined
- Dec 21, 2010
- Messages
- 73
I've tried about half a dozen different methods to export sheets to a single pdf. The closest I've gotten has failed after trying to export with Run Time Error 1004, stating "document not saved. The document may be open, or an error may have been encountered when saving".
Any idea what I can do here? There are two sheets, named Operation List and Tool List. I want them into a single PDF but will settle for two different PDFs. Thanks!
Excel 2010.
Any idea what I can do here? There are two sheets, named Operation List and Tool List. I want them into a single PDF but will settle for two different PDFs. Thanks!
Excel 2010.
Code:
Sub SaveCertainWorksheetsAsPDF()
'Save the active sheet as a .PDF with the filename in cell B1
'File will be saved in the same directory as this file
Dim sFileName As String, sht As Worksheet
For Each sht In Worksheets
With sht
sFileName = .Range("B1").Value
.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:="C:\" & sFileName & ".pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=False, _
IgnorePrintAreas:=False, OpenAfterPublish:=False
End With
Next
End Sub
Last edited: