How to Attach a Macro Module

Hi,

i have an excel sheet which contains macros in 3 modules, when i try to copy all the worksheets to another workbook the modules are not copied. Can u provide me code snippet to perform this?

Many thanks

Senthil kumar K.

1 Reply

GM Geetha M Syncfusion Team September 15, 2009 04:51 AM UTC

Hi Senthil,

The macros are stored in the workbook and they won't be copied when each worksheets are copied. You may need to generate a new workbook from the existing one.

IWorkbook workbook = application.Workbooks.Open(@"..\..\TestSample.xls");
workbook.SaveAs("Sample.xls");
workbook.Close();
excelEngine.Dispose();

Please try this and let me know if you have any questions.

Regards,
Geetha

Loader.
Up arrow icon