-
I want to print an Adobe Acrobat PDF file from within a Visual Basic 6 program - I don't need to view it or anything like that, I just want to print it - I know that if you right click the file in Windows Explorer, it gives you the option to print - Can I use an API call to do this exact same thing????? Thanks in Advance!!!!!!!!!
GENE
-
'\\ Declaration
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
Using this api and passing "Print" in the lpOperation parameter causes windows to print out the document using whichever application is associated with that document. The code to use this from a VB form is:
Public Sub PrintDocument(ByVal sDocumentName As String)
Const SW_HIDE = 0
Dim lRet As Long
LRet = ShellExecute(Me.hWnd, "Print", sDocumentName, "","",SW_HIDE)
End Sub
If ShellExecute is successful, the return value (lRet) will be greater than 32.
-
MerrionComputin,
This is fine but how do we terminate the program we used to print from after we have finished with it. Using the hide operator keeps the app open in its hidden state.
Thanks :)