首页 > 解决方案 > C# VSTO SaveCopyAs 签入的演示文稿/文档

问题描述

我在 C#.Net 中为 MS-Office 创建了一个 VSTO 加载项,它可以将所有幻灯片/页面导出为图像。

但是,如果演示文稿/文档是从远程 SharePoint 站点打开的,并且演示文稿/文档需要在可以编辑之前签出,我将无法导出幻灯片/页面。但是,我不想更改/更新远程文件中的任何内容,我只想将该文件的副本复制到“temp”文件夹中,以便可以将幻灯片/页面导出为图像。

我正在使用以下代码创建演示文稿的临时副本

Presentation vstoPresentation = Globals.ThisAddIn.Application.ActivePresentation;
var filename = vstoPresentation.Name;
var tempPath = System.Environment.GetEnvironmentVariable("temp");
string temp_file = tempPath + "\\" + filename;
vstoPresentation.SaveCopyAs(temp_file);

我收到以下错误

System.Runtime.InteropServices.COMException (0x80048240): Presentation (unknown member) : Invalid request.  Presentation cannot be modified.
   at Microsoft.Office.Interop.PowerPoint._Presentation.SaveCopyAs(String FileName, PpSaveAsFileType FileFormat, MsoTriState EmbedTrueTypeFonts)
   at PowerPointExport.ThisAddIn.ExportImages() in F:\Path\to\project\PowerPointExport\ThisAddIn.cs:line 271

在此处输入图像描述

标签: c#sharepointvstoms-office

解决方案


目前尚不清楚传递给该SaveCopyAs方法的实际字符串是什么样的......

作为一种解决方法,您可以尝试使用Presentation.SaveAs方法来保存从未保存过的演示文稿,或者以不同的名称保存以前保存的演示文稿


推荐阅读