Printer object question


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Printer object question

  1. #1
    Alam Guest

    Printer object question


    I am using printer object in VB to print my report.
    The problem is I want to use a network printer located in another area from
    the area where this program will run. The mahcine where my program will run,
    has a default printer set through Cotrol Pannel-> Printers tab in Windows
    NT.
    I am using this code to search for all printers and by reading .DeviceName
    and then matching that device name with one from my ini file and if found
    then set it to default.

    Say the default printer on my machine is "\\TEXAS\SHIP_P"
    I want to print my report to a printer "\\TEXAS\INSP_P"
    I am using this code:

    Dim RemotePrinter as Object

    'say strTEmp="\\TEXAS\INSP_P"
    '(strTEmp is a public variable. It reads Printer name from an 'ini file)

    For Each RemotePrinter In Printers
    If RemotePrinter.DeviceName Like strTEmp Then
    Set RemotePrinter= Printer
    Exit For
    End If
    Next RemotePrinter

    Printer.Print="This text needs to be printed on that printer"
    Printer.EndDoc

    Now whats happening is every time I try to print to that INSP_P printer,
    the report prints to the SHIP_P printer that is default to my computer. I
    have tried to add this line before Set line
    Printer.TrackDefault=False
    but it gave me same results.
    Help!

  2. #2
    Phil Weber Guest

    Re: Printer object question

    > Dim RemotePrinter as Object

    Alam: Change the above to:

    Dim RemotePrinter as Printer

    > If RemotePrinter.DeviceName Like strTemp Then
    > Set RemotePrinter = Printer
    > Exit For
    > End If


    Change the above to:

    If RemotePrinter.DeviceName Like strTemp Then
    Set Printer = RemotePrinter
    Exit For
    End If

    If that still doesn't work, see the following article in the Microsoft
    Knowledge Base:

    FIX: Setting Printer to Item in the Printers Collection Fails
    ( http://support.microsoft.com/support.../q167/7/35.asp )

    ---
    Phil Weber



  3. #3
    Alam Guest

    Re: Printer object question


    Thanks Phil!
    It seems to be working fine. Only thing is this that report format gets changed
    when it prints to a different printer than default. It may be Printer objects
    bug.

    Thanks again.


    "Phil Weber" <pweber@teleport.com> wrote:
    > > Dim RemotePrinter as Object

    >
    >Alam: Change the above to:
    >
    > Dim RemotePrinter as Printer
    >
    > > If RemotePrinter.DeviceName Like strTemp Then
    > > Set RemotePrinter = Printer
    > > Exit For
    > > End If

    >
    >Change the above to:
    >
    > If RemotePrinter.DeviceName Like strTemp Then
    > Set Printer = RemotePrinter
    > Exit For
    > End If
    >
    >If that still doesn't work, see the following article in the Microsoft
    >Knowledge Base:
    >
    > FIX: Setting Printer to Item in the Printers Collection Fails
    > ( http://support.microsoft.com/support.../q167/7/35.asp )
    >
    >---
    >Phil Weber
    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center