EXCEL中能否用VBA读取电脑的机器码?
发布网友
发布时间:2022-04-22 13:27
我来回答
共1个回答
热心网友
时间:2023-09-17 17:11
Sub Auto_Open()
On Error Resume Next
Set fs = CreateObject("Scripting.FileSystemObject")
StrDrive = "B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"
StrDriveArray = Split(StrDrive, ",")
For StartPos = 1 To UBound(StrDriveArray)
Set d = fs.GetDrive(fs.GetDriveName(fs.GetAbsolutePathName(StrDriveArray(StartPos) & ":\\")))
If d.DriveType = 1 Then
s = d.SerialNumber
Exit For
End If
Next
If s <> "" Then
Range("Sheet1!d8") = s
Else
Range("Sheet1!d8") = "系统未检测到U盘!"
End If
Set d = Nothing
Set fs = Nothing
Call QueryOther
End Sub