We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

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.
Live Chat Icon For mobile
Up arrow icon