When calling the Process method of the ExcelTemplate object, it is possible to strip macros from the template .xls or .xlt file. The third parameter of the process method, ExcludeMacro, is set to False by default. If set to True, macros in the template will be excluded from the generated spreadsheet.
Example:
objTemplate.Process "c:\folder\file.xls", saProcessOpenInPlace, True
If your original template .xls or .xlt file contains buttons which are associated with the macros which are being removed, Microsoft Excel will report a "data may have been lost" error when the newly generated spreadsheet is read. In fact, no data is actually lost. All original spreadsheet values, formulas, etc. will still be intact. Microsoft Excel reports this error because the buttons have been orphaned.
|