Private Sub Workbook_Open()
'This will show the Userform 1 when starting and hide the excel sheet in the background
'Also checks to see if program has ever been run, and if not, loads program for the first time
Application.Visible = False
Dim s As String
Dim edate As String
Dim namer As String
Dim d As String
Dim ExpirationDate As String
ExpirationDate = edate
d = Sheets("Developer").Range("B39") 'registration key
edate = Sheets("Developer").Range("E37") 'expiration date
namer = Sheets("Notes").Range("N4") 'just a name
s = GetSetting("DemoTest", "Registration", "Username")
If s = "" Then
Sheets("Developer").Unprotect Password:=Worksheets("Developer").Range("B15:E15").Value
Sheets("Developer").Range("B34:F34").ClearContents
s = InputBox("Welcome to the " & namer & " Voyage Reporting System." & vbCrLf & "Please input the appropriate name to initialize the system for the first time." & vbCrLf & vbCrLf & "Note: this information can be modified later by clicking on the [Developer] button.", namer, "Bridge")
'UserForm17.Show
's = UserForm17.TextBox1
If s <> "" Then
's = UserForm17.TextBox1.Value
Sheets("Developer").Range("B34") = s
SaveSetting "DemoTest", "Registration", "Username", s
Sheets("Notes").Visible = xlSheetVisible
Sheets("Notes").Select
Sheets("Developer").Unprotect Password:=Worksheets("Developer").Range("B15:E15").Value
Sheets("Developer").Range("C36") = Date
'If s <> "" Then MsgBox "Welcome to the " & name & " Voyage Reporting System." & vbCrLf & "Please input the appropriate data to initialize the system for the first time." & vbCrLf & vbCrLf & "Note: this information can be modified later by clicking on the [Developer] button.", vbOKOnly, name
Application.Visible = True
End If
Else:
'If ExpirationDate > edate Then
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: d = Application.InputBox("Your workbook date has expired. Please enter the registration key to renew your license.", namer)
If d = CStr(Worksheets("Developer").Range("B39").Value) Then
Sheets("Developer").Range("C36") = Date
MsgBox "Welcome Back " & s, vbOKOnly, namer
End If
End If
'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
End Sub