Excel Interop打开excel并禁用宏

Nis*_*ant 8 .net excel interop com-interop

在加载excel文件之前,C#中是否有办法在excel中关闭宏.我正在使用Excel Interop加载excel文件.我只能看到VB.NET的解决方案.

谢谢Nishant

Joh*_*ner 21

我想你可以在你的Excel应用程序上设置它:

Excel.Application xapp = new Excel.Application();
xapp.AutomationSecurity = Microsoft.Office.Core.MsoAutomationSecurity.msoAutomationSecurityForceDisable;
Run Code Online (Sandbox Code Playgroud)