Charts AddChart()在WithWindow=false打开演示文稿时抛出

Charts AddChart()在WithWindow=false打开演示文稿时抛出,charts,powerpoint,office-interop,Charts,Powerpoint,Office Interop,我不确定这是否是“有意的”,或者是否存在解决方法(显示演示文稿除外) 自动化时无法隐藏PowerPoint演示文稿是非常令人恼火的。这个问题有解决办法吗 #if DEBUG var withWindow = Microsoft.Office.Core.MsoTriState.msoTrue; #else // using msoTrue fixes the error var withWindow = Microsoft.Office.Core.MsoTriState.m

我不确定这是否是“有意的”,或者是否存在解决方法(显示演示文稿除外)

自动化时无法隐藏PowerPoint演示文稿是非常令人恼火的。这个问题有解决办法吗

#if DEBUG
    var withWindow = Microsoft.Office.Core.MsoTriState.msoTrue;
#else
    // using msoTrue fixes the error
    var withWindow = Microsoft.Office.Core.MsoTriState.msoFalse;
#endif

    presentation = app.Presentations.Open(templateFileName,
        Microsoft.Office.Core.MsoTriState.msoTrue, // readonly
        Microsoft.Office.Core.MsoTriState.msoFalse, // untitled (?)
        withWindow // with window: visible or not
        );

// some time later...
slide.Shapes.AddChart(); // Error HRESULT E_FAIL has been returned from a call to a COM component. ErrorCode: -214747259