07 Sep 2010 
Support Center » Knowledgebase » Automating creating PDFs from Word
 Automating creating PDFs from Word
Solution Problem:
How can I automate printing a Microsoft Word document to Win2PDF?

Solution:
The following sample code uses Microsoft Word and Win2PDF to create PDF files. The sample code bypasses Win2PDF's File Save dialog.
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Dim WdApp As Object
Set WdApp = CreateObject("Word.Application")

'save path and file name in registry for Win2PDF, to bypass file prompt
SaveSetting "Dane Prairie Systems", "Win2PDF", "PDFPostFileName", "c:\myfile.pdf"

With WdApp
.Documents.Open FileName:="c:\myfile.doc"
.Options.PrintBackground = True
.ActivePrinter = "Win2PDF"
.Visible = False
.ActiveDocument.PrintOut
.Documents.Close savechanges:=False
End With

'Verify Win2PDF is done creating PDF file
Do
   Sleep 10
   PDFRegKey = GetSetting("Dane Prairie Systems", "Win2PDF", "PDFPostFileName", "")
Loop While PDFRegKey Empty


Article Details
Article ID: 3
Created On: 21 Nov 2006 08:34 AM

 Login [Lost Password] 
Email:
Password:
Remember Me:
 
 Search
 Article Options
Home | Register | Submit a Ticket | Knowledgebase | Troubleshooter | Downloads
Language: