I use this in VBA within Access. It should also work in
Excel because it is using the Windows API
Function GetComputerName() As String
Dim lngLen As Long, lngX As Long
Dim strName As String
lngLen = 32
strName = String$(lngLen, 0)
lngX = apiGetComputerName(strName, lngLen)
If lngX <> 0 Then
GetComputerName = Left$(strName, lngLen)
Else
GetComputerName = ""
End If
End Function
You also need the following in the declarations for the
module where the function exists.
Public Declare Function apiGetComputerName Lib "kernel32"
Alias _
"GetComputerNameA" (ByVal lpBuffer As String, nSize As
Long) As Long
Hope that helps!
Kevin