valdemirofelberg Level: Graduate
 Registered: 18-12-2003 Posts: 12
|
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).
|