Sub SaveAsPDF()
Dim strFileName As String
Dim WordApp As Word.Application
strpath = "F:\PDF Files\"
strFileName = "test.docx"
Set WordApp = CreateObject("Word.Application")
WordApp.Documents.Open strpath & strFileName
' remove .doc or .docx from filename
If UCase(Right(ActiveDocument.name, 1)) = "X" Then
' .docx
strFileName = Left(ActiveDocument.name, Len(ActiveDocument.name) - 5)
Else
' .doc
strFileName = Left(ActiveDocument.name, Len(ActiveDocument.name) - 4)
End If
' write the PDF file
WordApp.ActiveDocument.ExportAsFixedFormat _
OutputFileName:=ActiveDocument.Path & "\" & strFileName & ".pdf", _
ExportFormat:=wdExportFormatPDF, _
OpenAfterExport:=False, _
OptimizeFor:=wdExportOptimizeForPrint, _
Range:=wdExportAllDocument, _
Item:=wdExportDocumentContent, _
IncludeDocProps:=True, KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, _
DocStructureTags:=True, _
BitmapMissingFonts:=True, _
UseISO19005_1:=False
WordApp.Quit
Set WordApp = Nothing
' all done
MsgBox "PDF complete"
End Sub
Aşağıdaki kodu dener misiniz?