Fairly new to VBA code here. I have a condition setup (under "This Workbook") upon opening a spreadsheet to verify a computer's predetermined motherboard serial number that will shut the Excel workbook down if the numbers do not match. This works fine. What I'd like to do is to add a second condition that will allow a password to be entered in a textbox if the numbers do not match so that the serial number condition could be manually overridden, if necessary. If the serial number and the password are incorrect the workbook automatically closes. Thanks in advance for any help!
Here is the code that works:
Private Sub Workbook_Open()
If CreateObject("Scripting.FileSystemObject").GetDrive("C:\").SerialNumber <> "-XXXXXXX" Then ActiveWorkbook.Close False
End Sub
Here is what I am attempting to do that is not functioning properly - need to add a textbox to enter a password to override an incorrect serial number
Private Sub Workbook_Open()
If CreateObject("Scripting.FileSystemObject").GetDrive("C:\").SerialNumber <> "-XXXXXXX" Then
Dim Rng
Rng = InputBox("aaaaaa")
If Rng <> "aaaaaa" Then ActiveWorkbook.Close False
End Sub
Here is the code that works:
Private Sub Workbook_Open()
If CreateObject("Scripting.FileSystemObject").GetDrive("C:\").SerialNumber <> "-XXXXXXX" Then ActiveWorkbook.Close False
End Sub
Here is what I am attempting to do that is not functioning properly - need to add a textbox to enter a password to override an incorrect serial number
Private Sub Workbook_Open()
If CreateObject("Scripting.FileSystemObject").GetDrive("C:\").SerialNumber <> "-XXXXXXX" Then
Dim Rng
Rng = InputBox("aaaaaa")
If Rng <> "aaaaaa" Then ActiveWorkbook.Close False
End Sub