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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Opening an excel file which contains macro

Thread ID:





75146 Jul 15,2008 03:13 AM UTC Mar 22,2016 05:48 AM UTC ASP.NET Web Forms (Classic) 5
Tags: XlsIO
Administrator [Syncfusion]
Asked On July 15, 2008 03:13 AM UTC

How to open an excel file using Syncfusion APIs, if the file contains macros?

Yavanaarasi G [Syncfusion]
Replied On July 15, 2008 05:30 AM UTC

Hi Venkatesan,

Thank you for your interest in Syncfusion products.

Normally an excel file is open with XlsIO using the below code snippet. The similar way is used to open the file that contains macros. It has no difference. But currently we have support only for preserving macros from the template. XlsIO does not have any support for manipulating/running macros at runtime.

Here is the code snippet:

//Step 1 : Instantiate the spreadsheet creation engine.
ExcelEngine excelEngine = new ExcelEngine();
//Step 2 : Instantiate the excel application object.
IApplication application = excelEngine.Excel;
//Open an existing spreadsheet
IWorkbook workbook = application.Workbooks.Open(@"..\..\VBATemplate.xls");

Please let me know if you have any other concerns.


Administrator [Syncfusion]
Replied On July 15, 2008 03:25 PM UTC

The only difference, the way I open the file is that file name not starting with the '@' symbol. I even put this command

workbook.DisableMacrosStart = true;

Is there a way to ignore that initial popup message comes for enable/disable macro and still open the file?

Yavanaarasi G [Syncfusion]
Replied On July 16, 2008 04:33 AM UTC

Hi Venkatesh,

The macros are enabled by default while opening spreadsheet and it can be disabled by DisableMacrosStart property in XlsIO. Also you can remove macros using the following code snippet:

myWorkBook.Application.SkipOnSave = SkipExtRecords.Macros;

Please try this and let me know if this helps.


Mangesh Hirave
Replied On March 18, 2016 02:40 PM UTC

I am working with macro enabled template (xltm) however, once opened at the time of saving the file I need to remove or at least disable the macros. I noticed the WordDocument has RemoveMacros() method available. Is there any similar functionality available for Excel? The follwing didn't work for me. The macros were still copied.
myWorkBook.Application.SkipOnSave = SkipExtRecords.Macros;

Ishwarya Narayanan [Syncfusion]
Replied On March 22, 2016 05:48 AM UTC


Hi Mangesh,


Sorry for the delay.


As you have created an incident with similar query, the response for this query will be updated in that incident. You can follow up the incident for further clarification regarding this query.

Please let us know if you have any concerns.

Ishwarya N


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon