Home  docPrint  docPrint-Pro  Support  ScreenShots

MS Word OLE Visual Basic - SDK sample

Word OLE VB sample is a simple Windows application that converts a MS Word document to PDF using Word OLE automation.

Download Evaluation Version of docPrint SDK
Purchase docPrint SDK

Private Sub PrintWord_Click()
' You need install MS Word in order to get this function to work

SetOutputFileName "C:\out.pdf"

On Error GoTo FileOpenDlg_ErrHandler
FileOpenDlg.CancelError = True
FileOpenDlg.Flags = cdlOFNFileMustExist Or cdlOFNPathMustExist _
	Or cdlOFNExplorer Or cdlOFNLongNames
FileOpenDlg.Filter = "MS Word documents (*.doc)|*.doc"
FileOpenDlg.FilterIndex = 1

On Error Resume Next
Dim wordApp As Object
Dim wDoc As Object

Set wordApp = CreateObject("Word.Application")

Err = 0
Set wDoc = wordApp.Documents.Open(FileOpenDlg.FileName, , 1)

If Err = 0 Then
	wordApp.ActivePrinter = sPrinterName
	Call wordApp.PrintOut(False)

	Set wDoc = Nothing
End If

Call wordApp.Quit
Set wordApp = Nothing

Exit Sub

End Sub

Copyright © 2000-2006 by VeryPDF, Inc.
Send comments about this site to the webmaster.