+ Reply to Thread
Results 1 to 6 of 6

I need to use my computer name to select a printer

  1. #1
    Registered User
    Join Date
    08-25-2016
    Location
    stoke, England
    MS-Off Ver
    office 2013
    Posts
    5

    I need to use my computer name to select a printer

    I currently using a excel spreadsheet to produce a label on a single PC however a number of staff have asked if they can have the spreadsheet on there machine to.

    The problem I have as the background sheets are always been updated with new info, I have put the file on however network drive but as each PC has a printer connected. The printer name is one of three names.

    My plan is for the spreadsheet to use the PC name to select the print.

    How can I use the PC name to select a print?

    I have tried sHostName = Environ$("computername") but I am a)struggling to display this variable on a UserForm and b) to use it to select a printer.

    Can anyone help?

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: I need to use my computer name to select a printer

    This is by no means ready to use, but meant to present the "makings" of a working approach, to give you a reasonable starting point to working out the rest.

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: I need to use my computer name to select a printer

    Hello maclevey

    You can invoke the system dialog to let the user select any printer installed on the user's machine with this line of code...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: I need to use my computer name to select a printer

    Right, in the code suggested in post #2, we are using that approach for any USERNAME the macro doesn't accurately detect the username to allow the user to select the printer on the fly.
    Last edited by JBeaucaire; 08-26-2016 at 11:51 AM.

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: I need to use my computer name to select a printer

    Hello maclevey,

    Here is a method that uses the WMI to return the names of installed printers. It can also return more information about each printer if you need it like if it is the default, it's location, etc.

    The function returns the printer names in a scalar zero based array. This can be loaded into a ListBox's or ComboBox's List property directly.

    Please Login or Register  to view this content.
    Last edited by Leith Ross; 08-26-2016 at 12:36 AM.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: I need to use my computer name to select a printer

    Maclevey, if these suggestions give you what you need to complete your task, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Select printer
    By dekueb in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-10-2016, 01:58 PM
  2. [SOLVED] Macro that select the printer
    By robrobet in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-13-2015, 03:43 PM
  3. [SOLVED] How do I select printer using VBA?
    By JS in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-12-2014, 07:32 AM
  4. Replies: 0
    Last Post: 11-18-2013, 03:43 AM
  5. Registering Printer Library on computer without printer installed (VBA)
    By Haydan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-10-2013, 03:30 AM
  6. Macro to Select Printer
    By JoeyDvivre in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-23-2010, 02:03 AM
  7. How can I select printer drawer?
    By Bafa in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-18-2008, 08:22 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1