Originally posted on microsoft forum but no answer yet :help:
Hi Gang
I found code that prints specific named sheets from my workbook to pdf. Now I need to add a table from one of the sheets as a separate pdf page. The extra issue is that this additional table needs to print in landscape, fit to 1 page. The other sheets are fine as they are. This code does refer to the RDB_Create_PDF function but I don't think that needs to change.......
The excellent code that I am currently using to print the multiple sheets is:
Sub RDB_Worksheet_Or_Worksheets_To_PDF()
Dim FileName As String
Dim vaWorksheets As Variant
vaWorksheets = Array("Cover", "Summary", "Service", "DataChart")
If ActiveWindow.SelectedSheets.Count > 1 Then
MsgBox "There is more then one sheet selected," & vbNewLine & _
"be aware that every selected sheet will be published"
End If
'Call the function with the correct arguments
'Tip: You can also use Sheets("Sheet3") instead of ActiveSheet in the code(sheet not have to be active then)
' FileName = RDB_Create_PDF(ActiveSheet, "", True, True)
FileName = RDB_Create_PDF(Sheets(vaWorksheets), "", True, True)
'For a fixed file name and overwrite it each time you run the macro use
'RDB_Create_PDF(ActiveSheet, "C:\Users\Ron\Test\YourPdfFile.pdf", True, True)
If FileName <> "" Then
'Ok, you find the PDF where you saved it
'You can call the mail macro here if you want
Else
MsgBox "Not possible to create the PDF, possible reasons:" & vbNewLine & _
"Microsoft Add-in is not installed" & vbNewLine & _
"You Canceled the GetSaveAsFilename dialog" & vbNewLine & _
"The path to Save the file in arg 2 is not correct" & vbNewLine & _
"You didn't want to overwrite the existing PDF if it exist"
End If
End Sub
The table is called tblServiceData and is on the Service sheet.
Thanks in advance!
Hi Gang
I found code that prints specific named sheets from my workbook to pdf. Now I need to add a table from one of the sheets as a separate pdf page. The extra issue is that this additional table needs to print in landscape, fit to 1 page. The other sheets are fine as they are. This code does refer to the RDB_Create_PDF function but I don't think that needs to change.......
The excellent code that I am currently using to print the multiple sheets is:
Sub RDB_Worksheet_Or_Worksheets_To_PDF()
Dim FileName As String
Dim vaWorksheets As Variant
vaWorksheets = Array("Cover", "Summary", "Service", "DataChart")
If ActiveWindow.SelectedSheets.Count > 1 Then
MsgBox "There is more then one sheet selected," & vbNewLine & _
"be aware that every selected sheet will be published"
End If
'Call the function with the correct arguments
'Tip: You can also use Sheets("Sheet3") instead of ActiveSheet in the code(sheet not have to be active then)
' FileName = RDB_Create_PDF(ActiveSheet, "", True, True)
FileName = RDB_Create_PDF(Sheets(vaWorksheets), "", True, True)
'For a fixed file name and overwrite it each time you run the macro use
'RDB_Create_PDF(ActiveSheet, "C:\Users\Ron\Test\YourPdfFile.pdf", True, True)
If FileName <> "" Then
'Ok, you find the PDF where you saved it
'You can call the mail macro here if you want
Else
MsgBox "Not possible to create the PDF, possible reasons:" & vbNewLine & _
"Microsoft Add-in is not installed" & vbNewLine & _
"You Canceled the GetSaveAsFilename dialog" & vbNewLine & _
"The path to Save the file in arg 2 is not correct" & vbNewLine & _
"You didn't want to overwrite the existing PDF if it exist"
End If
End Sub
The table is called tblServiceData and is on the Service sheet.
Thanks in advance!