workbook open click delays

sassriverrat

Well-known Member
Joined
Oct 4, 2018
Messages
655
I've pulled an excerpt of coding from my workbook_Open coding. When the wrong password is input into the inputbox, the input box disappears and nothing happens. I have to hit the keyboard (or mouse) to have the "wrong password" msgbox popup. Further, if I click cancel, it doesn't close the workbook (no other workbooks open), rather, it does the EXACT same scenario as if it were the wrong password and hitting the mouse brings up a wrong password message. What have i done wrong here?

Thanks

Code:
Private Sub Workbook_Open()

Application.Visible = False
Dim namer As String
Dim d As Variant

'ExpirationDate = (Sheets("Developer").Range("E37"))     'expiration date
'edate = Sheets("Developer").Range("E37")
namer = Sheets("Notes").Range("N4")                     'just a name

Else:
    If ExpirationDate > Date Then
        If ActiveWorkbook.name = "Master Voyage Report.xlsm" Then
             UserForm1.Show
        ElseIf ActiveWorkbook.name = "Current Voyage Report.xlsm" Then
             UserForm2.Show
        Else: UserForm3.Show
        End If
    Else:
TryAgain:
        d = InputBox("Your workbook date has expired. Please enter the registration key to renew your license.", namer)
        If d = vbCancel Then GoTo Closer
        If d = "" Then GoTo Wrong
        If d = CStr(Worksheets("Developer").Range("B39").Value) Then
            Sheets("Developer").Range("C36") = Date
            MsgBox "Welcome Back " & s, vbOKOnly, namer
        Else: GoTo Wrong
        End If
        If ActiveWorkbook.name = "Master Voyage Report.xlsm" Then
             UserForm1.Show
        ElseIf ActiveWorkbook.name = "Current Voyage Report.xlsm" Then
             UserForm2.Show
        Else: UserForm3.Show
        End If
    End If
        
'Application.Visible = True   'inserted just to check workbook
'Protects/Hides sheets on startup
Dim sh As Worksheet
    For Each sh In ActiveWorkbook.Worksheets
        If sh.name = "Notes" Then
            sh.Protect Password:=Worksheets("Developer").Range("B17:E17").Value, UserInterfaceOnly:=True
            End If
        If sh.name = "Ports" Then
            sh.Protect Password:=Worksheets("Developer").Range("B19:E19").Value, UserInterfaceOnly:=True
            End If
        If sh.name = "Developer" Then
            sh.Protect Password:=Worksheets("Developer").Range("B15:E15").Value, UserInterfaceOnly:=True
            End If
    Next sh
    
Exit Sub
'Closing code
Closer:
    If Workbooks.Count > 1 Then
        ActiveWorkbook.Close
    Else: Application.Quit
    End If
Exit Sub

'Wrong coding
Wrong:
            MsgBox "Password Incorrect, Please try again.", vbCritical, namer
            GoTo TryAgain
    
End Sub
 
Last edited:

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,214,649
Messages
6,120,730
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top