我目前有一个宏,它会在打开后获取运行Excel的机器的主板序列号。
然后它将验证我的Sheet1中是否存在此序列号VBA,如果它存在,它将打开Excel,否则它将关闭它。
以下是获取Seriel Number的代码。
Public Function MBSerialNumber() As String
Dim objs As Object
Dim obj As Object
Dim WMI As Object
Dim sAns As String
Set WMI = GetObject("WinMgmts:")
Set objs = WMI.InstancesOf("Win32_BaseBoard")
For Each obj In objs
sAns = sAns & obj.SerialNumber
If sAns < objs.Count Then sAns = sAns & ","
Next
MBSerialNumber = sAns
End Function
以下是验证部分
Private Sub Workbook_Open()
Set RMBSN = Sheets(1).Range("C4") ' This is where you have already stored required MBSerialNumber
If MBSerialNumber <> RMBSN Then ' Checking if current machine serial number is matching with required
MsgBox ("Data Security failier, This workbook will close") ' In case it does not match workbook will be closed
ActiveWorkbook.Save
ActiveWorkbook.Close
End If
End Sub
我现在要做的是,移动允许的值&#34;允许&#34;表格之外的序列数字 - 也许是在线的某个地方,这样我就可以在线添加这些值,而无需在每次我想给某人访问时在表单中提供这些值。
这可能吗?有什么建议?