删除Excel文档操作窗格

时间:2013-04-09 06:58:34

标签: c# excel excel-vba vsto excel-interop vba

我们可以使用Developer->将文档操作窗格附加到任何excel文件扩展包 - > Microsoft操作窗格 - >连接。

保存excel并再次打开它之前将存储excel文档。

enter image description here

我有一个Excel文件(参考图片),我希望在c#中使用inter op编程删除(分离)文档操作窗格。是否可以这样做?

代码段:

Application xlApp = null;
try
     {
        xlApp = new Microsoft.Office.Interop.Excel.ApplicationClass();
        string versionNo = xlApp.Version;
        xlApp.Visible = true;
        Microsoft.Office.Core.MsoAutomationSecurity mso = xlApp.AutomationSecurity;
        xlApp.AutomationSecurity = Microsoft.Office.Core.MsoAutomationSecurity.msoAutomationSecurityForceDisable;
        Workbook newWb = xlApp.Workbooks.Open(fileName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

         // Here want code to detach document action pane.
    }

1 个答案:

答案 0 :(得分:1)

试试这个:

Microsoft.Office.Interop.Excel.Application.DisplayDocumentActionTaskPane = false;