In a Windows environment the easiest way is:
ComputerName = VBA.Environ("ComputerName")
If that doesn't give you what you want you can use an API:
Public Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long
Go to
http://msdn.microsoft.com and search for "GetComputerName" for details about this.
Or you can use the Windows script host:
Include a Reference to: "Window Script Host Object Model" (file C:\WINDOWS\system32\wshom.ocx) and do the following:
Dim objSH As New IWshRuntimeLibrary.WshNetwork
ComputerName = objSH.ComputerName
While Windows systems should all have the wshom.ocx file, adding this Reference can make your application vulnerable to having a "MISSING" reference.
Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org