Results 1 to 3 of 3

Thread: Printers.........H........E..........L..........P?????????

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2000
    Posts
    81

    Post

    i want to use code that looks for the default printer then saves the index then looks for a printer by printer name and defaults that printer and after printing is complete the original printer is put back to been the default printer.

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Try something like this:
    Code:
    Private Sub Command1_Click()
        Dim sLastPrinter As String
        
        sLastPrinter = SetPrinter("Generic / Text-Only")
        If Len(sLastPrinter) Then
            'Printer Switched Successfully, do the Printing..
            Printer.Print "Printing with a Different Printer.."
            Printer.EndDoc
            'Switch Back to the Original Printer
            Call SetPrinter(sLastPrinter)
        End If
    End Sub
    
    Function SetPrinter(ByVal PrinterName As String) As String
        Dim oPRINTER As Printer
        For Each oPRINTER In Printers
            If LCase(oPRINTER.DeviceName) = LCase(PrinterName) Then
                'Found Specified Printer, Switch to it..
                SetPrinter = Printer.DeviceName
                Set Printer = oPRINTER
                Exit For
            End If
        Next
    End Function
    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]
    Certified AllExperts Expert

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2000
    Posts
    81

    Post

    Thanks Aaron that worked great!!!




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