Forum Discussion
Error when saving macro workbook as non-macro VBA
- Sep 08, 2023
It might be that strFile is too long (the maximum length of a sheet name is 31), or that it contains characters that aren't allowed in a sheet name: \ , / , * , ? , : , [ , ].
When the code is paused, press Ctrl+G to activate the Immediate window, type
? strFile
and press Enter.
strFile is a filename without path, ending in .xlsx
But the line
wb.SaveAs Filename:=strFile, FileFormat:=15
has file format 15; this stands for .wk3, a Lotus 1-2-3 file format! I think you want
wb.SaveAs Filename:=myFile, FileFormat:=xlOpenXMLWorkbook
- TheNeedsOfManySep 08, 2023Copper ContributorGood catch! Made the changes but am still getting the error. 😞
- HansVogelaarSep 08, 2023MVP
Temporarily change the line
On Error GoTo errHandler
to
On Error GoTo 0
When the error occurs, click Debug in the error message box.
Which line is highlighted?
- TheNeedsOfManySep 08, 2023Copper Contributor
wsPaste.Name = strFile
Do I have it in the wrong order? I'm trying to set a default filename for the user who wants to save a copy (which seems to be working as intended in the Save As dialogue box).