VBA: save document to path from variable

Kristina96

New Member
Joined
Sep 30, 2019
Messages
33
Hello all,

In have a file path saved as the variable "File_Path". Now I want to save a workbook to that path.
I'm using the following code:
Code:
WB2.SaveAs Filename:= _        File_Path _
        , FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False

It is not recognising "File_Path" as the variable though. What do I have to change?
Thank you and regards,
Kristina
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Can you please show the whole code?
Also what error number & message do you get?
 
Upvote 0
I can't share the code as it is multiple pages and confidential.
But the variable File_Path is a path to a folder on my computer. The macro is opening another document, makes changes to the document and should then save it to the path "File_Path".

I'm getting a runtime error 1004.
 
Upvote 0
What is the error message?
Also how is File_Path declared & how is it assigned a value?
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,208
Members
452,618
Latest member
Tam84

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