How to print pdf files to printer
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
Re: How to print pdf files to printer
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