Chris Macro
Well-known Member
- Joined
- Nov 2, 2011
- Messages
- 1,345
- Office Version
- 365
- Platform
- Windows
I am trying to make a File SaveAs macro that can save in different formats.
This Works:
This Doesn't Work:
I'm guessing its because I am setting my FileFormat variable as a string but I am not sure how else to go about making this code variable.
When I try the following code, I get an error stating that an object is required
This Works:
Code:
ActiveWorkbook.SaveAs Filename:="C:\Users\Chris\Desktop\Book1.xlsx", _
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
This Doesn't Work:
Code:
FileFormat = "xlOpenXMLWorkbook"
ActiveWorkbook.SaveAs Filename:="C:\Users\Chris\Desktop\Book1.xlsx", _
FileFormat:=FileFormat, CreateBackup:=False
I'm guessing its because I am setting my FileFormat variable as a string but I am not sure how else to go about making this code variable.
When I try the following code, I get an error stating that an object is required
Code:
Set FileFormat = xlOpenXMLWorkbook