borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Print to TIFF format)Next Topic (How Printing to USB port in VB6) New Topic New Poll Post Reply
AndreaVB Forum : Printing : Object Printer in local net
Poster Message
valdemirofelberg
Level: Graduate

Registered: 18-12-2003
Posts: 12

icon Object Printer in local net

I have a possession when using the object Printer in local net. When I select a printer of the local net through CommomDialog.ShowPrinter, the report doesn't obey the choice and it always prints in the local printer. Would anybody have a solution to help me? At once I thank.

04-02-2004 at 05:52 PM
View Profile Send Email to User Show All Posts | Quote Reply
steve_w
Level: Moderator


Registered: 18-04-2003
Posts: 1156
icon Re: Object Printer in local net

Hi

The following code worked for me. The printed I selected was not my default printer by the way.

Private Sub Command2_Click()

    CommonDialog1.ShowPrinter

    Printer.Print "Hello World"
    Printer.EndDoc

End Sub


If you are still having problems post up your code pls and I'll have a look

Cheers Steve

05-02-2004 at 09:50 AM
View Profile Send Email to User Show All Posts | Quote Reply
valdemirofelberg
Level: Graduate

Registered: 18-12-2003
Posts: 12
icon Re: Object Printer in local net

I work with more than a printer and each one has an own form/paper : paper of 5 roads for receipt emission (impact), paper of 2 roads for recibo(impact) and a paint jet for several reports. For the user not to need to worry in choosing the printer constantly, each form selects the printer automatically when it is open.  
In the event form_load I call the procedure that configures the printer and step the name of the appropriate printer.

Sub DefineImpressoraPadrão(ByVal Impressora As String)

If VarType(Impressora) <= 1 Then Exit Sub
If Impressora = "" Then Exit Sub

Dim I As Integer, X2
For I = 0 To Printers.Count - 1
    If Printers(I).DeviceName = Impressora Then
       X2 = WriteProfileString("windows", "device", Printers(I).DeviceName & "," & Printers(I).DriverName & "," & Printers(I).Port)
       Set Printer = Printers(I)
       Exit For
    End If
Next I
    DoEvents
    Printer.EndDoc

End Sub


Then the user should just click in the button of printing, but the report doesn't come out in the selected printer. Optional the user can choose other printer to print his/her report, however I have a command button to select the printer and other to print. In the command button of configuring the printer has the following code:  

CommonDialog1.ShowPrinter
DoEvents


In the button of printing just use the impression commands:   Printer.print "Teste"
  
However none in the two ways works appropriately. If the user doesn't have a local printer, the code works. He/she only gives problem when the user has a local printer (the first impression after opening the system always works, however when opening the form for the second time the impression he/she already begins to leave in the local printer).  

05-02-2004 at 10:30 AM
View Profile Send Email to User Show All Posts | Quote Reply
steve_w
Level: Moderator


Registered: 18-04-2003
Posts: 1156
icon Re: Object Printer in local net

I'll look at the first bit in a moment, but for the commondialog control try the following

CommonDialog1.PrinterDefault = True
CommonDialog1.ShowPrinter

05-02-2004 at 10:42 AM
View Profile Send Email to User Show All Posts | Quote Reply
steve_w
Level: Moderator


Registered: 18-04-2003
Posts: 1156
icon Re: Object Printer in local net

And the first part. When you pass in the printer name, is it in the format \\server\printername or printerabc on server.

The device name has it in the format \\server\printername

05-02-2004 at 10:50 AM
View Profile Send Email to User Show All Posts | Quote Reply
valdemirofelberg
Level: Graduate

Registered: 18-12-2003
Posts: 12
icon Re: Object Printer in local net

I pass printerabc on server.

05-02-2004 at 12:24 PM
View Profile Send Email to User Show All Posts | Quote Reply
steve_w
Level: Moderator


Registered: 18-04-2003
Posts: 1156
icon Re: Object Printer in local net

try

\\server\printerabc

05-02-2004 at 12:27 PM
View Profile Send Email to User Show All Posts | Quote Reply
valdemirofelberg
Level: Graduate

Registered: 18-12-2003
Posts: 12
icon Re: Object Printer in local net

Now it worked. I think he/she didn't have wrong with the code that I put here, the problem was in the report that also had a command of selecting the printer. I eliminated these commands and it is everything working now. Thank you very much for the help and excuse for disturbing.

05-02-2004 at 03:59 PM
View Profile Send Email to User Show All Posts | Quote Reply
steve_w
Level: Moderator


Registered: 18-04-2003
Posts: 1156
icon Re: Object Printer in local net

You're welcome  

05-02-2004 at 04:06 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Printing : Object Printer in local net
Previous Topic (Print to TIFF format)Next Topic (How Printing to USB port in VB6) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder