在Powerpoint Interop中循环浏览文本框时出错

我正试图在Interop的帮助下从演示文稿中删除一些形状。这是我写的代码:

var pptApp = new ApplicationInterop();
var presentation = pptApp.Presentations.Open(Paths.resavedAsPptxPresentation);
foreach (microsoft.Office.Interop.PowerPoint.Slide slide in presentation.Slides)
{
    foreach (microsoft.Office.Interop.PowerPoint.Shape shape in slide.Shapes)
    {
        if (shape.HasTextFrame == microsoft.Office.Core.MsoTriState.msoTrue)
        {
             if (shape.TextFrame.HasText == microsoft.Office.Core.MsoTriState.msoTrue)
             {
                 if (isWeiterShapeInterop(shape.TextFrame.textrange.Text))
                 {
                     shape.TextFrame.textrange.Text = "";
                 }
             }
        }
    }
}
presentation.SaveAs(Path.Combine(Paths.tempDataDirectory,"tempPresentation.pptx"));
presentation.Close();
pptApp.Quit();

运行它时,我收到错误消息:System.Runtime.InteropServices.COMException (0x800A01A8): Exception from HRESULT: 0x800A01A8 at microsoft.Office.Interop.PowerPoint.Shape.get_HasTextFrame()

调试显示pptApp完全出问题了。发生故障之前,pptApp.active设置为msoFalse

请帮助

wei981106811 回答:在Powerpoint Interop中循环浏览文本框时出错

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3030125.html

大家都在问