VBA code using fPath

Miasha

New Member
Joined
Oct 26, 2010
Messages
15
When I run the following code, I get the 'invalid procedure, call or argument - runtime error 5' message. I did not write this code - so I looked at the VBA code and noticed that it is trying to append the file name based on a specified range.
***********************
'Creates a string variable for the file path to save the with Summary page
Dim fPathA As String
fPath = "L:\DOCS\" & Range("A6") & "\" & Range("L9") & " " & Range("A5") & "(with Summary Page).pdf"

Here is the actual Macro
'Saves the with Summary Page without opening it.
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
fPathA, Quality:= _
xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=False, _
OpenAfterPublish:=False

When I try to run this, I get the error message mentioned above. HOWEVER, when I remove & Range("A6") & "\" - the macro runs just fine. Since these ranges are used as part of the file name, how can I rewrite this macro in order to get all of the ranges specified as part of the file name?
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,224,524
Messages
6,179,308
Members
452,904
Latest member
CodeMasterX

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