Results 1 to 7 of 7

Thread: Set Any Printer To Be The Predeterminated Printer

  1. #1

    Thread Starter
    Member orozcore's Avatar
    Join Date
    Aug 2005
    Posts
    36

    Unhappy Set Any Printer To Be The Predeterminated Printer

    Set Any Printer To Be The Predeterminated Printer


    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
    and save this selections using this

    Code:
    strReceiptPrinter = lstReceiptPrinter.Text
    strInfoProductPrinter = lstInfoProductPrinter.Text
    strReportsPrinter = lstReportsPrinter.Text
    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
    to call this procedure i do this

    Code:
            SetMyPrinter strReportsPrinter
            dtrTicket.PrintReport
    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

    Code:
    SetMyPrinter strInfoProductPrinter
    dtrInfoProduct.PrintReport
    
    SetMyPrinter strReceiptPrinter
    dtrTicket.PrintReport
    Here's a List of the Printers I have Installed:

    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


    I'm an Angel Walking in Darkness

  2. #2

  3. #3
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    Re: Set Any Printer To Be The Predeterminated Printer

    this is a nice (free) utility that will do what you want -

    I have used it without failure in my old company - and it's completely free!!

    I haven't used the other app 'delay' included, though, it's attached though, becuase that's how it came to me - enjoy
    Attached Files Attached Files
    Last edited by ZeBula8; Sep 30th, 2005 at 07:57 PM.

  4. #4

    Thread Starter
    Member orozcore's Avatar
    Join Date
    Aug 2005
    Posts
    36

    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

    I'm an Angel Walking in Darkness

  5. #5
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    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:
    1. 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.

    Example: SDP.EXE Okidata

  6. #6
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Set Any Printer To Be The Predeterminated Printer

    Quote Originally Posted by orozcore
    THX RhinoBull.
    This is that i was looking for. ...
    Excellent!

    Quote 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
    I have no idea what you're talking about. Sorry.

  7. #7

    Thread Starter
    Member orozcore's Avatar
    Join Date
    Aug 2005
    Posts
    36

    Question 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.



    I'm an Angel Walking in Darkness

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width