Error creating pdf files from Excel 2013 macro

KathyS_893

New Member
Joined
Apr 7, 2013
Messages
1
I have just moved from a laptop running XP/Excel 2007 to a laptop running Windows 8 64-bit/Excel 2013.

I have a .xlsm file that contains a macro which prints various sheets from the graph into 7 pdf files stored in other folders. The part of code that creates (i.e. overwrites the existing pdfs) is:

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
myPath & myfilename & ".pdf" _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False

The value of myPath is derived from the workbook's path. This macro has always worked fine on my old laptop, and has been running successfully on other XP/Excel 2007 computers that share the same folder structure.

However on my Windows 8 laptop running Excel 2013, it usually reports a 1004 error (i.e. can't save the file) on the first instance of the above code. However the first pdf file HAS actually been created. Also, if I re-run the macro, sometimes it will create 3 or 4 of the pdf files, and fail (with the same error) only on the last ones.

Does anyone have any ideas about what could be causing this change in behaviour, or can anyone suggest a better method of reliably creating these pdf files in Excel 2013?
 

Some videos you may like

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Watch MrExcel Video

Forum statistics

Threads
1,123,278
Messages
5,600,695
Members
414,400
Latest member
Damocles2021

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
Top