Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Excel > Excel Programming

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 04-26-2019, 08:15 AM
hickeyt hickeyt is offline Windows 10 Office 2007
Novice
 
Join Date: Apr 2019
Posts: 5
hickeyt is on a distinguished road
Default Computer Name

Is there a VBA function to return the computer name?
Reply With Quote
  #2  
Old 04-26-2019, 10:19 AM
hickeyt hickeyt is offline Windows 10 Office 2007
Novice
 
Join Date: Apr 2019
Posts: 5
hickeyt is on a distinguished road
Default Answer

Application.Username will return the name of the PC
Reply With Quote
  #3  
Old 04-26-2019, 01:22 PM
NoSparks NoSparks is offline Windows 7 64bit Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 685
NoSparks will become famous soon enoughNoSparks will become famous soon enough
Default

Are you sure about that?
Or is it not the computer name that you really want?

On my computer, In the vba Immediate window, these lines give three different results.
Only one is the actual computer name.
Code:
? Application.Username

? Environ$("username")

? Environ$("computername")
Reply With Quote
  #4  
Old 04-26-2019, 01:37 PM
Alansidman's Avatar
Alansidman Alansidman is offline Windows 10 Office 2019
Novice
 
Join Date: Apr 2019
Location: Steamboat Springs
Posts: 14
Alansidman is on a distinguished road
Default

An alternative means to get the same results

Code:
Option Explicit

Sub CompName()
    MsgBox (Application.UserName)
    MsgBox (Environ("username"))
    MsgBox (Environ("computername"))
End Sub
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Font and Format changes from computer to computer / device FHANNAN87 Outlook 1 04-19-2017 03:28 PM
New computer RetamaRobert Office 3 03-25-2011 02:14 PM
New Computer Rayddd Outlook 1 01-13-2011 07:32 AM
Should I buy new software for a new computer? Balliol Office 1 12-27-2010 03:09 PM
Computer Stolen-Install Office 2007 On New Computer corndale Office 0 08-23-2010 09:52 AM


All times are GMT -7. The time now is 10:06 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft