Excel Interop to open excel with macros disabled

calendar_today Asked May 2, 2012
thumb_up 8 upvotes
history Updated April 16, 2026

Question posted 2012 · +3 upvotes

Is there a way in C# to switch off macros in excel before loading an excel file. I am loading the excel file using Excel Interop. All I can see is solutions for VB.NET.

Thanks Nishant

Accepted answer +8 upvotes

I think you can just set it on your Excel Application:

Excel.Application xapp = new Excel.Application();
xapp.AutomationSecurity = Microsoft.Office.Core.MsoAutomationSecurity.msoAutomationSecurityForceDisable;

Excel VBA objects referenced (4)

  • Application — Using events with the Application object
  • Application — Working with Other Applications
  • Microsoft.Office — Controlling One Microsoft Office Application from Another
  • Microsoft.Office — List the Name and Office Location of Each Manager Belonging to an Exchange Distribution List

Top excel Q&A (6)

+8 upvotes ranks this answer #106 out of 167 excel solutions on this site .