【问题标题】:How do I open an already openeded presentation with PresentationDocument.Open() for PowerPoint Add in?如何使用 PresentationDocument.Open() for PowerPoint Add in 打开已打开的演示文稿?
【发布时间】:2014-05-23 23:13:36
【问题描述】:

我有一个用于创建、修改和保存演示文稿的 PowerPoint 插件。打开的演示文稿的特定选项应使用 Open XML 存储在此演示文稿文件 (.pptx) 中,当我尝试这样做时,我得到一个 IOException:

**System.IO.IOException : The process cannot access the file 'test.pptx' because it is being used by another process.**

这是代码中的一个sn-p:

**

using (PresentationDocument pptPackage = PresentationDocument.Open(fileName, true))
{
// add options to pptx file.
}

**

谢谢。

【问题讨论】:

    标签: c# vsto powerpoint openxml openxml-sdk


    【解决方案1】:

    如果您只需要使用 Open XML 阅读打开的演示文稿,您可以这样做:

    using (Stream stream = new FileStream(_fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
    using (PresentationDocument pptPackage = PresentationDocument.Open(stream, false))
    {
        // read pptx file.
    }
    

    但您不能以这种方式更改演示文稿。

    【讨论】:

      猜你喜欢
      • 2020-11-03
      • 1970-01-01
      • 2023-02-24
      • 1970-01-01
      • 2020-02-07
      • 2012-07-03
      • 2013-06-03
      • 2013-12-14
      • 1970-01-01
      相关资源
      最近更新 更多