ユーザーがボタンをクリックしてファイル名を選択し、pdf ファイルとして保存できるようにする Word アドインを作成しました。
しかし、多くの場合、ユーザーは次のエラーを受け取ります: 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
ファイルは保存されません。