首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PowerPoint生成和活动演示错误

PowerPoint生成和活动演示错误
EN

Stack Overflow用户
提问于 2011-01-05 05:03:23
回答 1查看 2.3K关注 0票数 0

在我的windows form app中,我想用一张幻灯片生成一个简单的ppt文件,并将一些文本转储到其中。这个过程应该是隐藏的(不启动PowerPoint或打开现有的ppt文件/模板),直到文件保存对话框出现。但是,文件保存操作会抛出一个异常,说明没有活动的表示。有没有人能解释一下?

代码语言:javascript
复制
    using PowerPoint = Microsoft.Office.Interop.PowerPoint;
    using Office = Microsoft.Office.Core;
    ...
    PowerPoint.Application pptApp = new PowerPoint.Application();
    PowerPoint.Presentations ppts = pptApp.Presentations;
    PowerPoint.Presentation ppt = ppts.Add(Office.MsoTriState.msoTrue);
    PowerPoint.Slides slides = ppt.Slides;
    PowerPoint.Slide slide = slides.Add(1, PowerPoint.PpSlideLayout.ppLayoutBlank);
    PowerPoint.Shapes shapes = slide.Shapes;
    PowerPoint.Shape shape = shapes.AddTextbox(Office.MsoTextOrientation.msoTextOrientationHorizontal, 0, 0, 500, 50);
    shape.TextFrame.TextRange.InsertAfter("foo");

    System.Windows.Forms.SaveFileDialog fd = new System.Windows.Forms.SaveFileDialog();
    if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
    {            
        //This line throws an exception: Invalid request. There is no active presentation.
        pptApp.ActivePresentation.SaveAs(fd.FileName,PowerPoint.PpSaveAsFileType.ppSaveAsPresentation, Office.MsoTriState.msoTrue);
    }

谢谢,

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-01-05 05:09:04

您应该将ppt变量另存为You ()。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4598396

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档