A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
I'm actually not what the -4143 equates to. I suspect it is saying "whatever default format has been set in Excel".
With Excel 2007/2010 the filename extension needs to match the specified FileFormat parameter (which is the position where your -4143 is showing up at). If you don't specify a FileFormat parameter, it saves in the format setup in Excel as the default which can be .xls, .xlsx or .xlsm (and probably others such as .xlts and .xltm for templates).
Best to match explicitly using code like
ThisWorkbook.SaveAs FilePath, fileformatParameter
Where fileformatParameter can be:
xlExcel8 (has numeric value of 56) to save with .xls file extension
xlOpenXMLWorkbookMacroEnabled (has numeric value of 52) (use with .xlsm files)
or
xlOpenXMLWorkbook (has numeric value of 51) (use with .xlsx files)
As for working with the template and saving it without triggering the Workbook_BeforeClose() event, here is one way:
Just before you get ready to save the file as a template file again, go into the VB Editor and type this into the Immediate window:
Application.EnableEvents=False [Enter]
That will prevent any events, including the _BeforeClose() event, from firing off. You can then save the file without the annoyance of the forced save to a different file type.
The problem with the Application.EnableEvents=False statement is that it is persistent, so no other events will fire until it is re-enabled. You could go back into the VB Editor and type this into the Immediate window:
Application.EnableEvents=True [Enter]
or just shut down Excel and re-open it, doing that will reset the .EnableEvents feature to =True.