2012-06-19 83 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

回答