VBA: save document to path from variable

Kristina96

New Member
Joined
Sep 30, 2019
Messages
31
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
 

Some videos you may like

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
40,995
Office Version
365
Platform
Windows
Can you please show the whole code?
Also what error number & message do you get?
 

Kristina96

New Member
Joined
Sep 30, 2019
Messages
31
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.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
40,995
Office Version
365
Platform
Windows
What is the error message?
Also how is File_Path declared & how is it assigned a value?
 

Watch MrExcel Video

Forum statistics

Threads
1,099,626
Messages
5,469,785
Members
406,670
Latest member
Jimborusk13

This Week's Hot Topics

Top