Exporting more than one worksheet as a Single PDF

mandukes

Forum Rules
Joined
May 25, 2013
Messages
90
Hi,

I need two macros that would do the following task.

1).
I want to save 2 of my worksheets as a single PDF file, with a flexibility of saving file at a user defined location. (SaveFileDialog).

2).
Also saving these 2 worksheets separately in a Workbook.


thanks :)
 
Last edited:

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
I have this code with a limited functionality. It can save only single file..


Code:
Sub CMSaveAsPDF(control As IRibbonControl)
Dim wsA As Worksheet
Dim wbA As Workbook
Dim strPath As String
Dim strFile As String
Dim strPathFile As String
Dim myFile As Variant
On Error GoTo errHandler


Set wbA = ActiveWorkbook


Set wsA = Worksheets("Design")
 
strPath = wbA.path
If strPath = "" Then
  strPath = Application.DefaultFilePath
End If
strPath = strPath & "\"




'create default name for savng file
strFile = "Design" 
myFile = Application.GetSaveAsFilename _
    (InitialFileName:=strPathFile, _
        FileFilter:="PDF Files (*.pdf), *.pdf", _
        Title:="Select Folder and FileName to save")


If myFile <> "False" Then
    wsA.ExportAsFixedFormat _
        Type:=xlTypePDF, _
        Filename:=myFile, _
        Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, _
        IgnorePrintAreas:=False, _
        OpenAfterPublish:=False
    'confirmation message with file info
    MsgBox "PDF file has been created: " _
      & vbCrLf _
      & myFile
End If
end sub
 
Last edited:
Upvote 0
Put both the sheets into the same book, select them both, then convert active sheet to PDF.

Here is a quick and dirty code sample: https://stackoverflow.com/questions/14404650/save-multiple-sheets-to-pdf
(note the top answer by Tim Williams and the additional comment within that answer by Pork)

Here is some more detailed info about working with multiple sheets, from a great VBA website with a ton of learning opportunities and free code: http://www.tushar-mehta.com/excel/vba/multiple_sheets.htm

If this doesn't answer your question, please clarify/elaborate (not sure whether the two sheets are already in the same workbook, or what you mean by your #2 ).

Tai

Tai
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,189
Members
452,616
Latest member
intern444

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