COMPUTERNAME
Returns the full computer name of where the code is running.
For instructions on how to add a function to a workbook refer to the page under Inserting Functions
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long
Function ReturnComputerName() As String
Dim sBuffer As String * 255
Dim lLength As Long
Dim sComputerName As String
sComputerName = ""
lLength = GetComputerName(sBuffer, 255)
lLength = InStr(1, sBuffer, Chr(0))
If (lLength > 0) Then
sComputerName = Left(sBuffer, lLength - 1)
Else
sComputerName = sBuffer
End If
ReturnComputerName = UCase(Trim(sComputerName))
End Function
The full computer name can be seen from (Start > Control Panel > System)(Computer Name tab).
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext