2012-06-19 77 views
1

我已经做了一个Word插件,它允许用户点击一个按钮,选择一个文件名并保存为PDF文件。无法保存word为pdf

但很多时候,用户会收到此错误: System.Runtime.InteropServices.COMException(0x80004005):(大致翻译自丹麦语:)文件被其他程序或用户使用。

尽管文件名不存在。

这里是我的代码:

If dlgSaveAsPDF.ShowDialog = System.Windows.Forms.DialogResult.OK Then 
    With Globals.ThisAddIn.Application 
     .ActiveDocument.ExportAsFixedFormat(OutputFileName:= _ 
    dlgSaveAsPDF.FileName, ExportFormat:= _ 
    wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _ 
    wdExportOptimizeForPrint, Range:=wdExportAllDocument, _ 
    Item:=wdExportDocumentWithMarkup, IncludeDocProps:=False, KeepIRM:=True, _ 
    CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _ 
    BitmapMissingFonts:=True, UseISO19005_1:=False) 
    End With 
    System.Diagnostics.Process.Start(dlgSaveAsPDF.FileName) 
End If 

文件永远不会被保存。

+0

确定文件名有pdf扩展名,并且不保留其doc(x)扩展名? – BugFinder

回答