Results 1 to 3 of 3

Thread: Print a file using API

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 1999
    Posts
    16

    Lightbulb

    HI!
    The idea is to print a file using VB6 and API!
    I want to print Tiff, Word, Excell and Acrobat files for example!
    Can anybody help me?
    Thanks,

  2. #2
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    To print a document with it's associated program, you can use the ShellExecute API.
    eg.
    Code:
    Option Explicit
    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 Sub PrintIt(ByVal sPath As String)
    Dim retVal As Long
        retVal = ShellExecute(hwnd, "print", sPath, vbNullString, vbNullString, 0&)
        If retVal <= 32 Then
            MsgBox "Error Printing" & vbCrLf & "DLL Error : " & Err.LastDllError
        End If
    End Sub
    
    Private Sub Command1_Click()
        Call PrintIt("g:\test1.txt")
    End Sub

  3. #3
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Maybe you can use BitBlt to draw on the printers DC.

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