Results 1 to 11 of 11

Thread: Quick question

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Talking

    I am attempting to still make a custom printer dialog. On load, acombo recives all printer devices. When I call my print routine, how can I write code to use what printer the user selected. I set a Global varaiable = SelP(Selected Printer) as string, but its not working (errors)..Any suggestions?
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  2. #2
    Addicted Member
    Join Date
    Aug 2000
    Location
    Fremont Ohio 43420
    Posts
    253
    Try putting this code into the cmdPrint sub or whatever you have named it

    dim thisprinter as printer

    private sub cmdprint

    for each thisprinter in printers
    if thisprinter.devicename = "" then
    set printer = thisprinter
    exit for
    end if
    next

    Hope this helps you out!!

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    This should help:


    Printers Property


    Returns a Printerscollection, which enables you to gather information about all the available printers on the system.

    Syntax

    Printers(index)

    The index placeholder represents an integer with a range from 0 to Printers.Count-1.

    Remarks

    The Printers collection enables you to query the available printers so you can specify a default printer for your application. For example, you may want to find out which of the available printers uses a specific printer driver. The following code searches all available printers to locate the first printer with its page orientation set to portrait, then sets it as the default printer:

    Dim X As Printer
    For Each X In Printers
    If X.Orientation = vbPRORPortrait Then
    ' Set printer as system default.
    Set Printer = X
    ' Stop looking for a printer.
    Exit For
    End If
    Next

    You designate one of the printers in the Printers collection as the default printer by using the Set statement. The preceding example designates the printer identified by the object variable X, the default printer for the application.

    Note If you use the Printers collection to specify a particular printer, as in Printers(3), you can only access properties on a read-only basis. To both read and write the properties of an individual printer, you must first make that printer the default printer for the application

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Cool Thank you. more questions...

    So once you SET the printer, as in Set Printer = thisprinter, then the printer is the associated with the one selected? I know these questions are lame, but I am trying to understand...

    Also, by using SET, does this change the default on the system, or just in the application?
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  5. #5
    Addicted Member
    Join Date
    Aug 2000
    Location
    Fremont Ohio 43420
    Posts
    253
    The Set will automatically goto that specific printer once it is selected. But if the user wants to select another printer then that print will become the default printer.

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Cool For which?

    For the application or the system?
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  7. #7
    Addicted Member
    Join Date
    Aug 2000
    Location
    Fremont Ohio 43420
    Posts
    253
    for the applications

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Thanks. that will help me out a great deal.

    Thank you jeffro and MartinLiss. I appreciate all your help. One last question on this subject, How can you determine the system default when pooling form all installed printers? ie. I want my combobox to show all, but have the default shown first.
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  9. #9
    Guest
    This should give you the default printer:
    Code:
    Dim Prnt As Printer 
    For Each Prnt In Printers 
        If Prnt.TrackDefault Then
            'this is the default printer, add the code here...
        End If
    Next

  10. #10

    Thread Starter
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441
    Sc0rp : Thanks for the last post.

    Thank you everyone.

    See you at my next post, creating text files, coming soon.
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  11. #11

    Thread Starter
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    prnt.Trackdefault

    I copied your code into my program. the trackdefault never gets set to true after looping all printers. Why would this occur, I do have a default printer.
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

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