+ Reply to Thread
Results 1 to 3 of 3

Adding Expiration Date and Days Left For Expiration Problem

Hybrid View

  1. #1
    Registered User
    Join Date
    05-07-2014
    Location
    Ghana
    MS-Off Ver
    Excel 2010
    Posts
    30

    Adding Expiration Date and Days Left For Expiration Problem

    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:
    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
    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.

    Any help please?

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,157

    Re: Adding Expiration Date and Days Left For Expiration Problem

    Private Sub Workbook_Open_()
        Application.Visible = False
        
        Load LoginForm 'It will be more correct
        LoginForm.Show
        
        'What's on the UserForm, what elements/fields ?
        'What data is taken from it, only the expire date ?
        
        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"
            
            Dim mbox As String '? Where is 'mbox' declaration ?
            
            '? Function or method ? i.e. 'InputBox' or 'Application.InputBox' ?
            mbox = Application.InputBox("Pls enter the password/code to continue...", "Password")
                    
            ' Maybe function ('InputBox') ?
            mbox = InputBox("Pls enter the password/code to continue...", "Password", "xxxxxxxxx")
            
            'In both of the above cases, the password you enter (at the time of writing) will be visible to everyone
        End If
        
        If mbox <> "ABC" Then
            Application.Visible = False '? It is already, at the beginning
        End If
        
            'MsgBox ("You have " & exdate - Date & "Days left")
            MsgBox ("You have " & CStr(exdate - Date) & " Days left") 'It will be more correct
            Application.Visible = True
            
        End If '??? Where is 'If ... Then' for this line ???
    End Sub
    And
    Quote Originally Posted by Newmord View Post
    I am using a workbook with set expire date. which runs behind userform at initiation ...
    Quote Originally Posted by Newmord View Post
    I am tying to to add expiration date and days left for expiration to the workbook with this code: ...
    ? Above you wrote "workbook with set expire date", so ... ?

    Quote Originally Posted by Newmord View Post
    I have a workbook with userform which runs the workbook behind the userform when initializing ...
    There is no such fact in the code ... (?)

    Attach some fragmentary, partial xls example, it will help get to know this topic better.

  3. #3
    Registered User
    Join Date
    05-07-2014
    Location
    Ghana
    MS-Off Ver
    Excel 2010
    Posts
    30

    Re: Adding Expiration Date and Days Left For Expiration Problem

    Login details to the attached file

    USERNAME: user
    PASSWORD: 1234
    EXPIRED PASSWORD: ABC

    Thanks in advance
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Formula to show days left before expiration
    By ldurham in forum Excel General
    Replies: 4
    Last Post: 03-29-2016, 11:15 AM
  2. [SOLVED] DATE EXPIRATION Formula
    By Reizor1989 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-28-2013, 04:34 PM
  3. Expiration Date
    By stevenchaplin in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 04-23-2013, 03:56 PM
  4. Put 10 days expiration
    By itselflearn in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-12-2013, 02:52 AM
  5. [SOLVED] A Formula to calculate expiration today +90 days out
    By JennK in forum Excel General
    Replies: 2
    Last Post: 03-30-2012, 06:03 PM
  6. Excel 2007 : Crossing the date of expiration
    By quaint_paradox in forum Excel General
    Replies: 1
    Last Post: 12-15-2011, 07:29 PM
  7. set expiration date
    By nhat8121 in forum Excel General
    Replies: 13
    Last Post: 01-05-2007, 10:02 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1