ExportAsFixedFormat : returning error

BeckieM

New Member
Joined
Jun 28, 2012
Messages
1
Thank you for reading my problem:

I have a spreadsheet with a couple of pivot tables and a master list. The master list is 3 columns : company name, contact name, contact email address.

My code iteratively runs down the list of email addresses and updates the page of the pivot table to show company-specific information. From here, it defines an appropriate print area (according to size of pivot table) and then I use the ExportAsFixedFormat function on that print range.

pRange1.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Fname1 _
, quality:=xlQualityStandard, includedocproperties:=True, ignoreprintareas:=False _
, openafterpublish:=False

pRange1 is the print range and Fname1 is the filename which will be of the format "H:\folder\[companyname]&[reportname].pdf

I have 90 email addresses on the list and, on running my code 42 times, it has only completed the list 3 times. On 3 occassions it failed on the first email, on 3 occassions it failed on the 3rd email address, on 2 occassions it failed on the 4th email address and so on.

I cannot determine any rhyme or reason for why it fails sometimes and works others.

I would appreciate any advice as I am a newbie to vba.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,216,747
Messages
6,132,483
Members
449,729
Latest member
davelevnt

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