Click to See Complete Forum and Search --> : How to print pdf files to printer


syamala
May 16th, 2001, 09:00 AM
hi,
I want to know how to print pdf files through VB.i know how to print word documents,declare as object and

Option Explicit
Dim o1 As Word.Application
Dim o2 As Word.Document
'Set o1 = CreateObject("word.application")
'
'Set o2 = o1.Documents.Open("c:\applcare.doc")
' Dim BeginPage, EndPage, NumCopies, i
' CommonDialog1.CancelError = True
' On Error GoTo ErrHandler
' CommonDialog1.ShowPrinter
' BeginPage = CommonDialog1.FromPage
' EndPage = CommonDialog1.ToPage
' NumCopies = CommonDialog1.Copies
' For i = 1 To NumCopies
' ' Put code here to send data to your printer.
' o1.Visible = True
' o1.Print


can you please help me how to print it.
Thanks in advance.
syamala

shree
May 16th, 2001, 10:32 AM
The following code should do it, if you have Adobe Acrobat in your system.

private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (byval hwnd as Long, byval lpOperation as string, _
byval lpFile as string, byval lpParameters as string, byval lpDirectory _
as string, byval nShowCmd as Long) as Long
private Const SW_HIDE = 0
private Sub Command1_Click()
ShellExecute me.hwnd, "print", "yourfile.pdf", vbNullString, vbNullString, SW_HIDE
End Sub

mgsuarezval
June 12th, 2002, 12:31 PM
shree, your code works fine, but it leaves an open Acrobat Reader window. I'm using Acrobat Reader 5.
Is this the normal behavior? and if it is, how can I close the window when the printing ends?
Thanks.