How to open an Excel 2013 Macro Enabled Template?
3 Nov 20251 minute to read
You can open and save an Excel 2013 Macro Enabled Template to XLSM (Excel 2013 Macro Enabled Document) format. The following code snippet illustrates this.
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
//Open an existing XLTM file
IWorkbook workbook = application.Workbooks.Open("Sample.xltm", ExcelOpenType.Automatic);
//Save the file as XLSM
workbook.SaveAs("Output.xlsm");
workbook.Close();
excelEngine.Dispose();
}using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
//Open an existing XLTM file
IWorkbook workbook = application.Workbooks.Open("Sample.xltm", ExcelOpenType.Automatic);
//Save the file as XLSM
workbook.SaveAs("Output.xlsm");
}Using excelEngine As ExcelEngine = New ExcelEngine()
Dim application As IApplication = excelEngine.Excel
application.DefaultVersion = ExcelVersion.Excel2013
'Open an existing XLTM file
Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xltm", ExcelOpenType.Automatic)
'Save the file as XLSM
workbook.SaveAs("Output.xlsm")
End Using