Hi. Thanks in advance all. I'm running Excel 2013 and I've written a macro to save a .xlsm to .xlsx, and I have a few questions about this. PROBLEM 1: When I run my save as code, I get a dialog which reads, "The following features cannot be saved in macro-free workbooks: VB Project. To save a file with these features, click No, and then choose a macro-enabled file type in the File Type list." If I press Yes the files saves as a .xlsx. However, if I press No to this dialog I get, "Run-time error '1004': VB Projects and XML sheets cannot be saved in a macro-free workbook." This dialog has two options - End or Debug. If I press Debug it takes me to this line of code:
The preceeding code is as follows:
QUESTION 1: How do I capture the runtime error 1004 so I can handle error appropriately without presenting users with End or Debug? QUESTION 2: How do I get this dialog NOT to appear? Can I do this programmatically? PROBLEM 2: When the file is saved as a .xlsx, even though I go into the VB editor and even though I do not see my macro code, the code is still executable in spite of the file extension being .xlsx. Why is this? When I save certain spreadsheets, I need to save them so the macros are removed and truly gone and can never be run again. How can I do this? Thanks. KJ
Code:
ActiveWorkbook.SaveAs Filename:=fileSaveName, FileFormat:=51
Code:
NewFilename = Trim(GetCellString("Customer Database", "B" & CustomerID) & "_" & NewInvoiceNum & ".xlsx") fileSaveName = Application.GetSaveAsFilename(InitialFileName:=NewFilename, filefilter:="Text Files (*.xlsx), *.xlsx") If fileSaveName <> False Then ' Save the new .xlsx and make the Customer Invoice worksheet current ActiveWorkbook.SaveAs Filename:=fileSaveName, FileFormat:=51
Last edited: