Newmord
New Member
I am new in VBA, please help.
I am using a workbook with set expire date. which runs behind userform at initiation
I have a workbook with userform which runs the workbook behind the userform when initializing.
I am tying to to add expiration date and days left for expiration to the workbook with this code:
My problems are;
1. When the expiration date is not due message box appears already but it still terminates the application.
2. When I turn off the Application.Visible = False under the mbox <> "ABC" Then, then the application will not terminate even if the password is false.
Attached is the sample file
Login details to the attached file
USERNAME: user
PASSWORD: 1234
EXPIRED PASSWORD: ABC
Any help please?
I am using a workbook with set expire date. which runs behind userform at initiation
I have a workbook with userform which runs the workbook behind the userform when initializing.
I am tying to to add expiration date and days left for expiration to the workbook with this code:
Code:
Private Sub Workbook_Open()
Application.Visible = False
LoginForm.Show
Dim exdate As Date
exdate = Format("10/12/2018", "DD/MM/YYYY")
If Date > exdate Then
MsgBox "Sorry! Evaluation period of the utility has expired." & vbCrLf & _
"Please consult the Administrator.", vbCritical, "Outdated/Expired Version"
mbox = Application.InputBox("Pls enter the password/code to continue...", "Password")
End If
If mbox <> "ABC" Then
Application.Visible = False
End If
MsgBox ("You have " & exdate - Date & "Days left")
Application.Visible = True
End If
End Sub
1. When the expiration date is not due message box appears already but it still terminates the application.
2. When I turn off the Application.Visible = False under the mbox <> "ABC" Then, then the application will not terminate even if the password is false.
Attached is the sample file
Login details to the attached file
USERNAME: user
PASSWORD: 1234
EXPIRED PASSWORD: ABC
Any help please?