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.
Unfortunately, activation email could not send to your email. Please try again.

Opening an excel file which contains macro

Thread ID:

Created:

Updated:

Platform:

Replies:

75146 Jul 14,2008 11:13 PM Mar 22,2016 01:48 AM ASP.NET Web Forms (Classic) 5
loading
Tags: XlsIO
Administrator [Syncfusion]
Asked On July 14, 2008 11:13 PM

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


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

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:

[C#]
//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.

Regards,
G.Yavana


Administrator [Syncfusion]
Replied On July 15, 2008 11:25 AM

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 12:33 AM

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.

Regards,
G.Yavana



Mangesh Hirave
Replied On March 18, 2016 10:40 AM

Hi,
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 01:48 AM

 

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.

Regards,
Ishwarya N


CONFIRMATION

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.

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.

;