try this (it must go in a module)
Code:
Declare Function GetComputerName Lib "kernel32.dll" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Public Function GetCompName() As String
Dim compname As String, retval As Long ' string to use as buffer & return value
compname = Space(255) ' set a large enough buffer for the computer name
retval = GetComputerName(compname, 255) ' get the computer's name
' Remove the trailing null character from the strong
compname = Left(compname, InStr(compname, vbNullChar) - 1)
GetCompName = compname
End Function
how's that?