Rickinnocal
New Member
- Joined
- Dec 14, 2010
- Messages
- 33
- Office Version
- 365
- Platform
- Windows
Hi, my code creates and saves a new Workbook. Works fine except that it saves it as "Filename.xls" even if I actually put in code to add 'xlsm', and using "FileFormat:=xlOpenXMLWorkbookMacroEnabled"
won't even save the code - it just goes red.
My current code is:
With the FileFormat:=xlOpenXMLWorkbookMacroEnabled commented out it runs fine saving the file with the name entered into the InputBox, and using .xls as an extension. I've tried various ways to force xlsm as an extension, or using the variant value of a Macro enabled workbook, but none of them work.
What am I doing wrong, please?
won't even save the code - it just goes red.
My current code is:
VBA Code:
sPath = "C:\"
sFileName = InputBox("Enter file name for new BQS eFile. Recommend Ship Name / Port / BQS eFile")
oFileName = ActiveWorkbook.Name
'set the sheet to be copied
Set wsCopy = ThisWorkbook.Worksheets("Prelim (FO)")
Set wb = Workbooks.Add
wb.SaveAs Filename:=(sFileName) FileFormat:=xlOpenXMLWorkbookMacroEnabled
Set wsPaste = wb.Sheets(1)
With the FileFormat:=xlOpenXMLWorkbookMacroEnabled commented out it runs fine saving the file with the name entered into the InputBox, and using .xls as an extension. I've tried various ways to force xlsm as an extension, or using the variant value of a Macro enabled workbook, but none of them work.
What am I doing wrong, please?