Saving multiple worksheets in a single PDF

Chuck6475

Board Regular
Joined
Sep 30, 2012
Messages
126
This forum has been invaluable to me, thanks for all of the past help and any that you can give with this issue.

My problem relates to PDF files. I use PDF's for a slide presentation of data from a variety of worksheets. Originally I modified some PDF software from Dominic (I think) from back in 2009 which required Adobe Acrobat too. That was a little pricey for the group that was using the software, so I found some code by kenneth Hobson, which used some of Excel's newer features to do the same thing.

Here is Kenneth Hobson's code:

Code:
Sub cPDFPrintAll()  cPublishAllToPDF Worksheets(Array("Record 1", "Record 2"))
  Worksheets("Record 2").Select
End Sub


Sub cPDFPrint1()
  cPublishAllToPDF Sheets(Array("Record 1"))
  Worksheets("Record 1").Select
End Sub


Sub cPDFPrint2()
  cPublishAllToPDF Sheets(Array("Record 2"))
  Worksheets("Record 2").Select
End Sub


Sub cPublishAllToPDF(o As Object)
  Dim fn As String
  fn = ThisWorkbook.Path & "\" & cGetBaseName(ThisWorkbook.Name) & ".pdf"
  o.Select
  cPublishToPDF fn, ActiveSheet
  Range("A1").Select
End Sub


Sub cPublishToPDF(fName As String, o As Object)
  Dim rc As Variant


  rc = Application.GetSaveAsFilename(fName, "PDF (*.pdf), *.pdf", 1, "Publish to PDF")
  If rc = "" Or rc = False Then Exit Sub
  
  o.ExportAsFixedFormat Type:=xlTypePDF, Filename:=rc _
  , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
  :=False, OpenAfterPublish:=False
End Sub


Function cGetBaseName(Filespec As String)
  Dim FSO As Object
  Set FSO = CreateObject("Scripting.FileSystemObject")
  GetBaseName = FSO.GetBaseName(Filespec)
End Function

I will admit, OO Methods are not my strong point. When I try and figure them out I get lost in the terminology and seemingly endless links.

What I'm trying to do is build a PDF file which will contain the PDF representation of a worksheet, which is modified some 30 to 50 times. I can produce the 30 to 50 pdf's as separate pdf's but I can't seem to get them to all reside in one file. I just lost I'm afraid.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,223,237
Messages
6,170,924
Members
452,366
Latest member
TePunaBloke

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