VBA TIPS
Retrieving the NetBIOS name of the local computer

The GetComputerName function retrieves the NetBIOS name of the local computer. This name is established at system startup, when the system reads it from the registry. If the local computer is a node in a cluster, GetComputerName returns the name of the cluster virtual server.

See details

Place following in the standard module.

Option Explicit

Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" _
                                              (ByVal Buffer As String, _
                                               Size As LongAs Long

Sub GetMachineName()
    Dim strBuf As String * 16, strPcName As String, lngPc As Long

    lngPc = GetComputerName(strBuf, Len(strBuf))
    If lngPc <> 0 Then
        strPcName = Left(strBuf, InStr(strBuf, vbNullChar) - 1)
        Debug.Print "Your Name of Computer is :" & strPcName
    Else
        Debug.Print "Error"
    End If
End Sub





| HOME |
Copyright © cellmasters.net - colo's junk room All Right Reserved
ABOUT
WORKS
THE CELL MASTERS
CONTACT
LINKS
Tips and Information about Microsoft Excel|Masaru Kaji aka Colo