Reputation: 157
I have a macro that opens a file, performs some formatting on the file, and then saves it as a new file. I have set as my file type .xlsx, and the file that I open is stored as .xlsx, yet when I save, it wants to save it as .xls, and then it won't open when I don't save it as .xls. What is wrong with my code?
I got the save as code from another website, so that could be part of the issue.
Sub Main()
'
'// non-related code above...
wBook.SaveAs Filename:=NewFile, _
FileFormat:=xlNormal, _
Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
Set ActBook = wBook
Workbooks.Open CurrentFile
ActBook.Close
End If
Application.ScreenUpdating = True
End Sub
Upvotes: 3
Views: 707
Reputation: 928
Try changing SaveAs.FileFormat
to xlOpenXMLWorkbook
wBook.SaveAs Filename:=NewFile, _
FileFormat:=xlOpenXMLWorkbook, ...
You can get more info on the Workbook.SaveAs
method here (MSDN link), and the xlFileFormat enumerations here (MSDN link).
Upvotes: 8