I would like to automate the conversion of an MS Word Document to a .pdf document using Visual Basic. Does anyone know how to go about doing this?
Thanks
1. Save your .doc as rtf.
2. Load into a VB richtextbox
3. Select PDFwriter as the default printer
3. Print the VB richtextbox
4. The result is a PDF file of your original .doc file.
Well, unfortunately not quite. The VB rich text box does not support all the formatting features used by Word, so it would only be a close approximation.
If you've got Word and Acrobat 5, it would be better to automate Word, and get Word to print to PDFWriter. Something like the following:
Option Explicit
Private Sub Command1_Click()
Dim myWord As Word.Application
Dim myDoc As Word.Document
Dim OriginalPrinter as string
Set myWord = New Word.Application
Set myDoc = myWord.Documents.Open("your_document_name"
OriginalPrinter = myWord.ActivePrinter
myWord.ActivePrinter = "PDFWriter"
myDoc.PrintOut
myWord.ActivePrinter = OriginalPrinter
myDoc.Close (False)
myWord.Quit
Set myWord = Nothing
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.