+ Reply to Thread
Results 1 to 8 of 8

Computer Name

Hybrid View

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

    Computer Name

    **EDITTED - thought id did it in the first place**

    I am looking a spreadsheet with userform to print labels.

    I am looking at the same spreadsheet but the label printers are of three make and therefore have 3 different name. I am looking at using the Computer Name to pick the correct print name. Also looking at displaying the Computer Name on the Userform


    Code so far

    Private Sub frmLABELS_Initialize()
      
    
    Dim strHostName As String
    
    strHostName = Environ("ComputerName")
    
    . 
    .
    .
    .
    
        Label9.Caption = strHostName.Value
        
    End Sub
    
    -------------------------------------------------------------------------------
    
    Private Sub cmdMORE_Click()
    
    .
    .
    .
    .
    
    Dim strDefaultPrinter As String
    Dim strLabelPrinter As String
    
    If strHostName = "NSHxxxxx1" Then
                 strLabelPrinter = "ZDesigner GK420t"
                 
       ElseIf strHostName = "NSHxxxxx2" Then
                 strLabelPrinter = "ZDesigner TLP 2844"
                 
        ElseIf strHostName = "NSHxxxxx3" Then
                 strLabelPrinter = "Zebra  TLP2844"
                 
       Else: strLabelPrinter = Application.ActivePrinter
      
    End If
    
    Worksheets("Sheet1").Range("B10") = frmLABELS.cboCLINIC.Value
    Sheets("Sheet1").Range("A1:B4").PrintOut ActivePrinter:=strLabelPrinter, Copies:=txtNO.Value
    Application.ActivePrinter = strDefaultPrinter
    
    End Sub
    I think this should work but when tested no it didnt.. Please Help... Where am I going wrog?
    Last edited by maclevey; 08-26-2016 at 05:18 PM.

  2. #2
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Computer Name

    Please put the code between code tags
    Try the following instead of the first part
    Private Sub UserForm_Initialize()
        Dim strHostName As String
    
        strHostName = Environ("ComputerName")
        Label9.Caption = strHostName
    End Sub
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Computer Name

    Welcome to the board, maclevey.

    Please take a few minutes to read the Forum Rules, and then edit your post to wrap your code with CODE tags.

    Thanks.

    EDIT: Thank you.
    Last edited by shg; 08-26-2016 at 05:24 PM.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Computer Name

    So: got it sorted?

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

    Re: Computer Name

    Quote Originally Posted by shg View Post
    So: got it sorted?
    nope sorry

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Computer Name

    How about ...

    Private Sub cmdMORE_Click()
      Dim sPrtDef       As String
    
      sPrtDef = Application.ActivePrinter
    
      Select Case Label19.Value
        Case "NSHxxxxx1"
          Application.ActivePrinter = "ZDesigner GK420t"
        Case "NSHxxxxx2"
          Application.ActivePrinter = "ZDesigner TLP 2844"
        Case "NSHxxxxx3"
          Application.ActivePrinter = "Zebra  TLP2844"
      End Select
    
      With Worksheets("Sheet1")
        .Range("B10") = frmLABELS.cboCLINIC.Value
        .Range("A1:B4").PrintOut Copies:=txtNo.Value
      End With
    
      Application.ActivePrinter = sPrtDef
    End Sub
    Last edited by shg; 08-26-2016 at 06:28 PM.

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

    Re: Computer Name

    looking good. we will try later

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Computer Name

    10-4 .

+ 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. ask about buy a old computer
    By ninhmoon in forum The Water Cooler
    Replies: 2
    Last Post: 11-04-2015, 05:37 AM
  2. VLookup works in my computer, but not in another user computer.
    By shiva_reshs in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-09-2013, 04:41 PM
  3. Replies: 6
    Last Post: 06-28-2013, 08:44 PM
  4. Replies: 1
    Last Post: 06-30-2012, 02:03 PM
  5. Replies: 0
    Last Post: 02-08-2010, 03:17 PM
  6. Auto Filter on my home computer differs from my work computer.
    By Sbova0226 in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 07-08-2009, 03:04 PM
  7. [SOLVED] How do I copy all Excel files from old computer to new computer?
    By Rfarsh in forum Excel General
    Replies: 2
    Last Post: 12-19-2005, 11:23 PM

Tags for this Thread

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