Runtime Error 5 when creating a PDF using a macro

dnwexcel1

New Member
Joined
Sep 22, 2014
Messages
1
I have a macro that creates a PDF of a sheet in my workbook and saves it to a specific location. I created this workbook using Excel 2010 and the macro works fine. However, I need to use it on a different computer that has Excel 2007 and for some reason, I keep getting a VBA runtime error 5 when I try to run the macro. The macros are enabled, and the location the spreadsheet is trying to save the PDF exists. Also, I've used this workbook on other computers with Excel 2007 without a problem. This computer also has Adobe and there is an option to manually save as a PDF, so I'm pretty sure the problem is with some sort of security setting or something like that, but I just can't figure out what it is. Here is the beginning of the code. There is more, but the debug says the last line shown is what is causing the problem.

Sub Macro3()
'
'export and save PDF


Sheets("Credit Criterion Check").Select
ActiveSheet.ExportAsFixedFormat Type:=x1TypePDF, Filename:= _
"C:\CREDIT CRITERION CHECK\" & ActiveSheet.Range("C1").Value & ".pdf", OpenAfterPublish:=True
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,214,938
Messages
6,122,346
Members
449,080
Latest member
Armadillos

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