Hello all,
Here's a tough one for the VBA wizards out there. I have a code that exports multiple spreadsheets as PDF's. Some of these spreadsheets have multiple pages. I would like to add to this code something that will add Bookmarks and subBookmarks to the PDF pages when it is exported. This specific code prints out 10 pages. I'd like to get the Bookmarks in the format:
Here is the code that I'm working with:
Sub MySheetsIntoPdf()
Call ExportSheetsAsPdf(ThisWorkbook.Path & "\AFE_Through Abandon.pdf", Sheet13, Sheet11, Sheet12, Sheet2, Sheet6, Sheet9, Sheet7)
End Sub
Sub ExportSheetsAsPdf(FileName As String, ParamArray exportedSheets() As Variant)
Dim WB As Workbook
Dim Sheet As Object
Dim i As Long
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set WB = Workbooks.Add
Set Sheet = exportedSheets(LBound(exportedSheets))
Sheet.Copy After:=WB.Sheets(1)
WB.Sheets(1).Delete
For i = LBound(exportedSheets) + 1 To UBound(exportedSheets)
exportedSheets(i).Copy After:=WB.Sheets(WB.Sheets.Count)
Next i
WB.ExportAsFixedFormat XlFixedFormatType.xlTypePDF, FileName, _
Quality:=xlQualityStandard, OpenAfterPublish:=False
WB.Close False
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "PDF file has been created"
End Sub
Thanks all!
Kelsey
Here's a tough one for the VBA wizards out there. I have a code that exports multiple spreadsheets as PDF's. Some of these spreadsheets have multiple pages. I would like to add to this code something that will add Bookmarks and subBookmarks to the PDF pages when it is exported. This specific code prints out 10 pages. I'd like to get the Bookmarks in the format:
- Title Page (PDF Page 1)
-Title Page details (PDF Page 2) - Cost (PDF Page 3)
- Graphs (PDF Page 4)
-Graph1 details (PDF Page 4)
-Graph2 details (PDF Page 5)
-Graph3 details (PDF Page 6) - Charts (PDF Page 7)
-Chart1 details (PDF Page 7)
-Chart2 details (PDF Page 8)
-Chart3 details (PDF Page 9)
-Chart4 details (PDF Page 10)
Here is the code that I'm working with:
Sub MySheetsIntoPdf()
Call ExportSheetsAsPdf(ThisWorkbook.Path & "\AFE_Through Abandon.pdf", Sheet13, Sheet11, Sheet12, Sheet2, Sheet6, Sheet9, Sheet7)
End Sub
Sub ExportSheetsAsPdf(FileName As String, ParamArray exportedSheets() As Variant)
Dim WB As Workbook
Dim Sheet As Object
Dim i As Long
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set WB = Workbooks.Add
Set Sheet = exportedSheets(LBound(exportedSheets))
Sheet.Copy After:=WB.Sheets(1)
WB.Sheets(1).Delete
For i = LBound(exportedSheets) + 1 To UBound(exportedSheets)
exportedSheets(i).Copy After:=WB.Sheets(WB.Sheets.Count)
Next i
WB.ExportAsFixedFormat XlFixedFormatType.xlTypePDF, FileName, _
Quality:=xlQualityStandard, OpenAfterPublish:=False
WB.Close False
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "PDF file has been created"
End Sub
Thanks all!
Kelsey