Moras imati instaliran Acrobat distiller (pojavice se kao stampac).
Posle toga, ova funkcija ce ti kreirati PDF fajl izabranog naziva.
Parametri su (sem prvog), Word dokument od koga se pravi PDF i naziv PDF (sa putanjom)
Code:
Public Function DOC2PDF(wWordApp As Word.Application, WordDoc As Word.Document, sPDFFile As String)
On Error GoTo Greska
Dim Fso ' As FileSystemObject
Dim sPrevPrinter ' As String
Dim oDistiller ' As PDFDistiller.PDFDistiller.1
Set Fso = CreateObject("Scripting.FileSystemObject")
Set oDistiller = CreateObject("PDFDistiller.PDFDistiller.1")
If oDistiller Is Nothing Then
MsgBox "Greška : PDF dokument se ne može kreirati. Adobe Acrobat Distiller nije dostupan", vbCritical, "GREŠKA"
GoTo Kraj
End If
sTempFile = Fso.GetSpecialFolder(TemporaryFolder) + "\" + Fso.GetTempName()
' Remember current active printer
sPrevPrinter = wWordApp.ActivePrinter
wWordApp.ActivePrinter = "Acrobat Distiller"
' Print the Word document to the Acrobat Distiller -
' will generate a postscript (.ps) (temporary) file
wWordApp.ActiveDocument.PrintOut False, , , sTempFile
wWordApp.ActivePrinter = sPrevPrinter
' Distill the postscript file to PDF
oDistiller.FileToPDF sTempFile, sPDFFile, "Print"
' Set oDistiller = Nothing
' Delete the temporary postscript file...
Fso.DeleteFile (sTempFile)
' Set fso = Nothing
GoTo Kraj
Greska:
MsgBox "Greška u kreiranju PDF dokumenta", vbInformation, "GREŠKA"
Kraj:
Set oDistiller = Nothing
Set Fso = Nothing
End Function