cái màu đo đỏ kg có , có cái này kg biết fù hợp kg?Các anh chị cho hỏi, trong Excel có hàm nào trả về tên PC hay tên người dùng PC không nhỉ?
Nếu không có hàm build-in nào thì xin cho 1 cái code để dùng trong VBA
Cảm ơn các anh chị
Function GetDriveSerialNumber(Optional ByVal DriveLetter As String) As Long Dim fso As Object, Drv As Object Set fso = CreateObject("Scripting.FileSystemObject") If DriveLetter <> "" Then Set Drv = fso.GetDrive(DriveLetter) Else Set Drv = fso.GetDrive(fso.GetDriveName(Application.Path)) End If With Drv If .IsReady Then DriveSerial = Abs(.SerialNumber) Else DriveSerial = -1 End If End With Set Drv = Nothing Set fso = Nothing GetDriveSerialNumber = DriveSerialEnd Function
Các anh chị cho hỏi, trong Excel có hàm nào trả về tên PC hay tên người dùng PC không nhỉ?
Nếu không có hàm build-in nào thì xin cho 1 cái code để dùng trong VBA
Cảm ơn các anh chị
Function GetComputername()
Application.Volatile
GetComputername = Environ("COMPUTERNAME")
End Function
Function GetUserName()
Application.Volatile
GetUserName = Environ("USERNAME")
End Function
Chắc bạn muốn cái này:
Mã:Function GetComputername() Application.Volatile GetComputername = Environ("COMPUTERNAME") End Function Function GetUserName() Application.Volatile GetUserName = Environ("USERNAME") End Function
Sub getip()
Set objWMIService = GetObject("winmgmts:\\" & "." & "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")
For Each IPConfig In IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then Sheet1.Range("A1").Value = IPConfig.IPAddress(0)
Next
End Sub