VBA Save As Macro, Returning Run-time Error 5 on other machines

rhhvbanovice

New Member
Joined
Aug 5, 2009
Messages
3
Hey,
New to VBA, mostly recording macros then editing what I can. I am trying to have a macro save a file as a PDF and extract the file name from a cell within the worksheet. The code works great on my computer but when I try to use it on any other computer it Returns run-time error 5. Here is the code, anything jump out?

Public Sub SaveAs()
'
' SaveAs Macro
Sheets("Report").Select
ChDir "\\JGNETWORK\jgmain\Personal Financial Statements"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"\\JGNETWORK\jgmain\Personal Financial Statements\" & Range("B5").Text, Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=True
End Sub


Thanks!
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
I'd bet that the following directoryis not accessible on the other users machines..

Code:
"\\JGNETWORK\jgmain\Personal Financial Statements\"
 
Upvote 0
I believe you are correct. The important thing, though, is that it generate the PDF with file name. Is there a location that I could enter that I could be sure would generate the file on all machines? Is "C:\" my only option?
 
Upvote 0
If that's the only reliable storage device then.. yes... you can always check to see if the path exists, and then if not, place it in a local directory, such as c:\PDFS
 
Upvote 0
I tried not specifying a path and on my computer it defaulted to Documents, yet on the other computer it still returned Run-time Error 5. If the cell I am using as a the file name contains a function would that effect the macro?
 
Upvote 0
Lose the following statement

Code:
ChDir [URL="file://\\JGNETWORK\jgmain\Personal Financial Statements"]\\JGNETWORK\jgmain\Personal Financial Statements[/URL]
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,214
Members
449,074
Latest member
cancansova

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