Manual Export to .pdf v VBA driven Export

mikeymay

Well-known Member
Joined
Jan 17, 2006
Messages
1,600
Office Version
  1. 365
Platform
  1. Windows
I have a number of sheets that require exporting to a .pdf file and each sheet has a print range establish that has the range name of 'Print_Area'

When this is performed manually by selecting all the sheets at once in a group, the established print ranges from each of the sheets are exported.

When I record this and place into a routine only the selected ranges in each of the sheets are exported. So if cell A1 is selected in each of the sheets, then only cell A1 is exported.

How do I tell Excel to export the range from each of the sheets (bearing in mnd the ranges will be different on each sheet) rather the the selected cells from each of the sheets?

Prior to selecting all the sheets/creating the sheet array I have tried to loop through each of the sheets to select the print range from each sheet, but as soon as all the sheets are selected then the print range from the first sheet is duplicated across all selected sheets.

The code below is a recording of the above being performed manually
Code:
Sheets(Array("Ownership Overview Table", "Ownership Overview Charts", _
        "Institutional Ownership Summary", "Global Buyers & Sellers", _
        "Global Investment Style", "Global Activity by Turnover", _
        "Global Regional & Country")).Select
    Sheets("Ownership Overview Table").Activate
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:= _
        strPDFFileName _
        , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
        :=False, OpenAfterPublish:=False

TIA
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Use the ExportAsFixedFormat method of the Workbook object instead...

Code:
[COLOR=#ff0000]ActiveWorkbook[/COLOR].ExportAsFixedFormat . . .

Note that there will be no need to select your sheets prior to exporting, assuming that you want to export all of your sheets within your workbook.
 
Upvote 0

Forum statistics

Threads
1,214,994
Messages
6,122,633
Members
449,092
Latest member
bsb1122

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