Results 1 to 3 of 3

Thread: Print a File

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Location
    Dubuque, IA
    Posts
    134

    Question

    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

  2. #2
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    '\\ 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.

  3. #3
    Junior Member
    Join Date
    Apr 2001
    Posts
    22
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width