-
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! 
-
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
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks