Bookmark Pages Exported to PDF

kgallego

Board Regular
Joined
Jul 26, 2011
Messages
82
Office Version
  1. 365
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:


  • 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
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,214,822
Messages
6,121,767
Members
449,049
Latest member
greyangel23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top