'----------------------------------------------------------------------
' 1) Microsoft Word 97 or above should be installed and activated on your PC.
'
' 2) Universal Document Converter 5.2 or above should be installed, too.
'
' 3) Open your project in Microsoft Visual Basic 6.0.
'
' 4) In Visual Basic main menu press "Project->References".
'
' 5) In the list of references check "Universal Document Converter Type Library".
'----------------------------------------------------------------------Private Sub PrintWordToPDF(strFilePath As String)
Dim objUDC As IUDC
Dim itfPrinter As IUDCPrinter
Dim itfProfile As IProfile
Dim WordApp AsObjectDim WordDoc AsObjectSet objUDC = New UDC.APIWrapper
Set itfPrinter = objUDC.Printers("Universal Document Converter")
Set itfProfile = itfPrinter.Profile
' Use Universal Document Converter API to change settings of converterd document
itfProfile.PageSetup.ResolutionX = 600
itfProfile.PageSetup.ResolutionY = 600
itfProfile.FileFormat.ActualFormat = FMT_PDF
itfProfile.FileFormat.PDF.ColorSpace = CS_TRUECOLOR
itfProfile.FileFormat.PDF.Multipage = MM_MULTI
itfProfile.OutputLocation.Mode = LM_PREDEFINED
itfProfile.OutputLocation.FolderPath = "C:\Out"
itfProfile.OutputLocation.FileName = "&[DocName(0)] -- &[Date(0)] -- &[Time(0)].&[ImageType]"
itfProfile.OutputLocation.OverwriteExistingFile = False' Run Microsoft Word as COM-serverOn Error Resume NextSet WordApp = CreateObject("Word.Application")
' Open document from file
Err = 0 ' Clear GetLastError() value
Set WordDoc = WordApp.Documents.Open(strFilePath, , 1)
If Err = 0 Then ' Print all pages of the document
WordApp.ActivePrinter = "Universal Document Converter"
Call WordApp.PrintOut(False)
' Close the documentCall WordDoc.Close
Set WordDoc = Nothing
End If' Close Microsoft WordCall WordApp.Quit
Set WordApp = Nothing
End Sub