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 objectApplication— Working with Other ApplicationsMicrosoft.Office— Controlling One Microsoft Office Application from AnotherMicrosoft.Office— List the Name and Office Location of Each Manager Belonging to an Exchange Distribution List
Top excel Q&A (6)
- Shortcut to Apply a Formula to an Entire Column in Excel +335 (2011)
- How should I escape commas and speech marks in CSV files so they work in Excel? +136 (2012)
- Convert xlsx to csv in linux command line +96 (2012)
- How to create a link inside a cell using EPPlus +50 (2011)
- IF statement: how to leave cell blank if condition is false ("" does not work) +44 (2013)
- T-SQL: Export to new Excel file +44 (2012)
excel solutions on this site
.