Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Computer name in VB code

Status
Not open for further replies.
Jul 30, 2004
4
US
How do I get the current Computer Name (or Workstation name) that an Excel VB module is running under?

Thanks
Bob
 
Hi Bob-

Try the Environment variables:

Code:
Msgbox VBA.Environ("COMPUTERNAME")

*cLFlaVA
----------------------------
A polar bear walks into a bar and says, "Can I have a ... beer?"
The bartender asks, "What's with the big pause?
 
If you're on a win9x box the %COMPUTERNAME% environment variable doesn't exist.
You may try something like this:
Set N = CreateObject("WScript.Network")
MsgBox "Computer Name = " & N.ComputerName
Set N = Nothing


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top