Very much new to VBA. Have been reading posts on here to try and learn and have utilised some of that expertise below.
I am trying to print multiple excel range names to one PDF.
This works OK for me when the range names (first, second and third) are all on one sheet (Sheet1)
The code so far is given here:
How can this be modified to allow for including additional range names (fourth, fifth and sixth) from a second sheet (Sheet2)?
I am trying to print multiple excel range names to one PDF.
This works OK for me when the range names (first, second and third) are all on one sheet (Sheet1)
The code so far is given here:
Code:
Sub pdfrangecombined()
Dim tempPDFFileName As String
Dim tempPSFileName As String
Dim tempPDFRawFileName As String
Dim tempLogFileName As String
tempPDFRawFileName = "c:\pdftest\trial"
'Define the postscript and .pdf file names.
tempPSFileName = tempPDFRawFileName & ".ps"
tempPDFFileName = tempPDFRawFileName & ".pdf"
tempLogFileName = tempPDFRawFileName & ".log"
Application.Range("first, second, third").Select
Selection.PrintOut Copies:=1, preview:=False, ActivePrinter:="Adobe PDF", printtofile:=True, Collate:=True, prtofilename:=tempPSFileName
'Create PDF File
Dim myPDFDist As New PdfDistiller
myPDFDist.FileToPDF tempPSFileName, tempPDFFileName, tempShowWindow
'Next
'Delete PS File
Kill tempPSFileName
Kill tempLogFileName
End Sub
How can this be modified to allow for including additional range names (fourth, fifth and sixth) from a second sheet (Sheet2)?