My thoughts
What I don't understand is the intention with this ...
d1 = DateSerial(2018, 12, 31)
d2 = Date
If d2 > d1 Then
since 1/3/2018 (d2) is before 12/31/2018 (d1) then d2 is NOT > d1 then check pw logic is skipped. Is that what you want?
I changed it to 12/31/2016 to test
1. In ThisWorkbook
Option Explicit
'http://pixcels.nl/disable-shift-key-on-open/
'fires first
Private Sub Workbook_Open()
mbMacrosEnabled = True
End Sub
2. In Standard Module
Option Explicit
Public mbMacrosEnabled As Boolean
'this fires after WB_Open
Sub customUIonLoad(ribbon As IRibbonUI)
Application.EnableCancelKey = xlDisabled
CheckShiftOnOpen
Application.EnableCancelKey = xlInterrupt
End Sub
Public Function CheckShiftOnOpen()
If Not mbMacrosEnabled Then
MsgBox "Don't press Shift on opening the workbook!", vbCritical, "Fatal error"
'Application.Quit <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
MsgBox "Application will .Quit here"
Else
Dim d1 As Date
Dim d2 As Date, Cnt As Integer
Dim password As String
d1 = DateSerial(2016, 12, 31) '<<<<<<<<<<<<<<<<<<<<<<<<<<<<< WHY 12/31/2018??? I changed it for test
d2 = Date
If d2 > d1 Then '<<<<< 1/3/2018 is NOT > 12/31/2018 so the 'PW question never runs
above:
password = InputBox("enter password")
If password = "abc123" Then
MsgBox ("Welcome!")
Else
MsgBox ("Incorrect password!")
Cnt = Cnt + 1
'3 trials of password input
If Cnt < 3 Then
GoTo above
Else
MsgBox "ACCESS DENIED"
'Application.Quit <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
MsgBox "Application will .Quit here"
End If
End If
Else
MsgBox ("Opening file")
End If
End If
End Function
PS -- thanks to SamT for that http://pixcels.nl/disable-shift-key-on-open/ link