Results 1 to 5 of 5

Thread: [RESOLVED] About Printer...

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2007
    Posts
    21

    Resolved [RESOLVED] About Printer...

    hello folks, I have a problem,
    I want to make a sub that changes the form and number of copies of the printer for the next print job, like:

    Private Sub SetPrinterForm(formName As String, copies As Long)

    I did the following code with no effects, I don't find where is the error,
    please, if you know where is it, please tell me,
    thanks a lot, Angel.

    Code:
    Private Sub SetPrinterForm(formName As String, copies As Long)
        Dim hPrinter As Long
        Dim cbRequired As Long
        Dim pd As PRINTER_DEFAULTS
        Dim pi2 As PRINTER_INFO_2
        Dim buff() As Long
        Dim dm As DEVMODE
        pd.DesiredAccess = PRINTER_ACCESS_USE Or PRINTER_ACCESS_ADMINISTER
        If (OpenPrinter(VB.Printer.DeviceName, hPrinter, pd) <> 0) Then
            If (GetPrinter(hPrinter, 2, 0&, 0&, cbRequired) = 0) Then
                ReDim buff(cbRequired) As Long
                If GetPrinter(hPrinter, 2, buff(0), cbRequired, cbRequired) <> 0 Then
                    Call CopyMemory(pi2, buff(0), Len(pi2))
                    dm = pi2.pDevMode
                    dm.dmFields = 0
                    dm.dmFields = DM_FORMNAME Or DM_COPIES
                    dm.dmFormName = formName & Chr(0)
                    dm.dmCopies = copies
                    pi2.pDevMode = dm
                    Call SetPrinter(hPrinter, 2, pi2, 0&)
                End If
            End If
            Call ClosePrinter(hPrinter)
        End If
    End Sub
    Last edited by angelherriv; Oct 30th, 2007 at 06:23 PM.

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