Hi, I'm trying to set any printer to be the Predeterminated in Windows.
The last time I had a problem getting the Printers of Windows. I have got that and there's no problem.
I get the Printers doing this
Code:
For Each PrinterLoader In Printers
frmMyPrinters.lstReceiptTicketPrinter.AddItem PrinterLoader.DeviceName
frmMyPrinters.lstInfoProductPrinter.AddItem PrinterLoader.DeviceName
frmMyPrinters.lstReportsPrinter.AddItem PrinterLoader.DeviceName
Next PrinterLoader
the Controls are contained in the form frmMyPrinters and are List Boxes
I fill the List Boxes to show them and the user can select the Printer to each activity is done in my programm
for example when I sell a Product I need to Print the information of the product and the Receipt at the same time.
I use the lstReceiptTicketPrinter.Text and the lstInfoProduct.Text to do this the .Text are the names of the printers.
An when i performe Reports I use the string variables
The three printers are Installed in the same PC including the four printer but i won't use that.
I set the Printer of the User-Selected-Printer doing this
Code:
Public Sub SetMyPrinter(MyPrinterName As String)
For Each MyPrinter In Printers
If MyPrinterName = MyPrinter.DeviceName Then
Set Printer = MyPrinter
End If
Next MyPrinter
End Sub
MyPrinterName in SetMyPrinter is the string of my Selected printer to perform the printing
and dtrTicket is my DataReport so I only call the Event of my DataReport, PrintReport
After this the Printing should be directed to my printer of the Receipts but it doesn't
I checked it after i SetMyPrinter the Printer.DeviceName is the same like the string argument.
So I realized that the printing is set to the Determinated Printer of Windows, so in this case is a Samsung SCX-4x16 Series, that is set like Predeterminated
And even if a try a lot of times seting any printer the printing is always send to that printer, but if a change the Predeterminated Printer in Windows to the ReceiptPrinter (EPSON TM-U220D Receipt) the printing is send to that printer.
So I need to perfome this
Change the Windows Predeterminated Printer every time I want to Printe the different Reports and Receipts because a Receipt and a Report must be printed at the same time.
I do this to do that with the strInfoProductoPrinter and the strReceiptPrinter
Samsung SCX-4X16 Series (Predeterminated)
EPSON LX-300+ (This must be changed at Run-Time to be Predeterminated)
EPSON TM-U2220D Receipt (This must be changed at Run-Time to be Predeterminated)
HP PSC 1310 Series
I HOPE SOMEBODY CAN HELP ME, BECAUSE I´M WORRIED ABOUT THIS
Re: Set Any Printer To Be The Predeterminated Printer
THX RhinoBull.
This is that i was looking for.
Maybe i was wrong saying "determinated" but you're right is "default"
Now i can change the 'default' printer and set my printers before printing.
Now tha problem i realize with my program is that when the DataReport is being Loaded, an error apear. Automation Error and when i close the Report my program exit itselft and i have to execute it again
Re: Set Any Printer To Be The Predeterminated Printer
using the sdp.exe utility you can use shell to change the printer to whatever printer you want, including network printers.
VB Code:
Shell "c:\sdp.exe HP4000", vbNormalNoFocus
The basic usage is: SDP.EXE <printer name>
Just type in all or part of the printer's name and/or port and SDP will
select the first device that it matches. The printer description is
CASE SENSITIVE! Epson is not the same as EPSON to SDP. You should run
SDP without parameters to see the case used. Also do no use quotes or
chevrons (< >) on the command line, just what it asks for.
Re: Set Any Printer To Be The Predeterminated Printer
Originally Posted by orozcore
THX RhinoBull.
This is that i was looking for. ...
Excellent!
Originally Posted by orozcore
...Now tha problem i realize with my program is that when the DataReport is being Loaded, an error apear. Automation Error and when i close the Report my program exit itselft and i have to execute it again
Re: Set Any Printer To Be The Predeterminated Printer
RhinoBull.
The Error that appears is this "Automation Error -2147417848" and it's before all the data contained on my Recordset is shown in the DataReport when the Report it's being loaded.
When i clikc OK the Report is Blank and I have to close it, sometimes when I close the Report my programm exits and i have to re-start my programm and that's a common error if i want to show a DataReport, and other times an error like this apears
The Instruction in "0x77f46b45" makes reference to the memory in "0x001eb750". The Memory can't be "Read"
Click on OK to finish the Program
Click Cancel to Depurate the Program
I always have to click on Ok to finish my program and run it again.
I haven't realized if the instruction number is the same always because i don't write the number, or the number of memory.
When this error apears is a critical error because it finishes my program and i have to re-start it.