+ Reply to Thread
Results 1 to 10 of 10

Excel File Expiry Coding with Renew Option

Hybrid View

  1. #1
    Registered User
    Join Date
    03-17-2016
    Location
    India
    MS-Off Ver
    2010
    Posts
    83

    Excel File Expiry Coding with Renew Option

    Dear Forum Experts,

    I have been trying to develop VBA Coding for File Expiry which allows the user to Renew by inputting the password by "user form" for every 8 Months otherwise file should be closed.

    Here I attached sample file which contains VBA Coding to Check expiry date and closes the file immediately, I want to upgrade the coding as above.


    Thank you...
    Attached Files Attached Files
    Thank You.....

  2. #2
    Registered User
    Join Date
    03-17-2016
    Location
    India
    MS-Off Ver
    2010
    Posts
    83

    Re: Excel File Expiry Coding with Renew Option

    Dear Forum Experts,

    Any Update Please...

  3. #3
    Valued Forum Contributor
    Join Date
    09-19-2008
    Location
    It varies ...
    MS-Off Ver
    Office365 - 64bit
    Posts
    862

    Re: Excel File Expiry Coding with Renew Option

    See the attached file which I think does what you're asking for.

    This goes in the Workbook_Open() event - there are two commented out lines which you should uncomment in the real code so that users cannot unhide the sheet that contains the expiry date and password.
    Option Explicit
    
    Public Sub Workbook_Open()
    'check if an expiry date has been set - if not set to now + 8 months.
    Dim wksHidden As Worksheet
    Dim celDate As Range
    Dim datExpiry As Date
    
        Set wksHidden = ThisWorkbook.Worksheets("DateStore")
        'wksHidden.Visible = xlSheetHidden
        Set celDate = wksHidden.Range("A1")
        If celDate.Value = Empty Then celDate.Value = DateAdd("m", 8, Now())
        datExpiry = celDate.Value
        If Now() > datExpiry Then Call Reset.Reset_Initialize
        'wksHidden.Visible = xlSheetVeryHidden
        
    End Sub
    And this goes in the form object:
    Option Explicit
    
    Public Sub btnClose_Click()
        Unload Me
    End Sub
    
    Public Sub btnReset_Click()
    Dim strPW As String
    Dim varMsg As Variant
    
        strPW = Trim(Me.txtPassword)
        If strPW = ThisWorkbook.Worksheets("DateStore").Range("B1").Value Then
            ThisWorkbook.Worksheets("DateStore").Range("A1").Value = DateAdd("m", 8, Now())
            varMsg = MsgBox("The file expiry date has been extended by 8 months and will now expire on " & Format(ThisWorkbook.Worksheets("DateStore").Range("A1").Value, "dd mmm yyyy"), vbInformation + vbOKOnly, "Code accepted")
        Else
            varMsg = MsgBox("You have entered an incorrect password and the expiry date will not be extended.", vbCritical + vbOKOnly, "Incorrect password")
        End If
        Call btnClose_Click
        
    End Sub
    
    Public Sub Reset_Initialize()
    Dim strFilename As String
        
        strFilename = Left(ActiveWorkbook.Name, (InStrRev(ActiveWorkbook.Name, ".", -1, vbTextCompare) - 1))
        Me.Caption = strFilename & " File  - Registration Key"
        Me.Show
    
    End Sub
    Hope that helps. MM.
    Attached Files Attached Files
    MatrixMan.
    --------------------------------------
    If this - or any - reply helps you, remember to say thanks by clicking on *Add Reputation.
    If your issue is now resolved, remember to mark as solved - click Thread Tools at top right of thread.

  4. #4
    Registered User
    Join Date
    03-17-2016
    Location
    India
    MS-Off Ver
    2010
    Posts
    83

    Re: Excel File Expiry Coding with Renew Option

    Thank you,,,


    its working......

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Excel File Expiry Coding with Renew Option


    Hi !

    As you must yet know there are several ways to open a workbook and bypassing its open event …

  6. #6
    Valued Forum Contributor
    Join Date
    09-19-2008
    Location
    It varies ...
    MS-Off Ver
    Office365 - 64bit
    Posts
    862

    Re: Excel File Expiry Coding with Renew Option

    Yes but most people don't code to get around all the tricks a user might try ... if someone really wants to break it, they will.

    @ Arshad - if you want to get around this issue, then just call the code at the start of the main code; you can declare a global variable (like "booChecked") as Boolean so you only run it once. Or just leave it if you think your users are not malicious.

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Excel File Expiry Coding with Renew Option


    As you must know Open event can be bypassed without any code, just by holding a key !

  8. #8
    Valued Forum Contributor
    Join Date
    09-19-2008
    Location
    It varies ...
    MS-Off Ver
    Office365 - 64bit
    Posts
    862

    Re: Excel File Expiry Coding with Renew Option

    Yes I'm aware ... my view stands though - for normal purposes, I don't think it's worth coding for purposeful evasion of functionality.

  9. #9
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Excel File Expiry Coding with Renew Option

    If you save your worksheets as very hidden

    Then use your macro to unhide them

    Then your worksheets cannot be viewed if Macros are disabled.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  10. #10
    Valued Forum Contributor
    Join Date
    09-19-2008
    Location
    It varies ...
    MS-Off Ver
    Office365 - 64bit
    Posts
    862

    Re: Excel File Expiry Coding with Renew Option

    yep - as in the code I provided :-)

+ 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. color coding based on expiry day
    By Emirates in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-05-2016, 05:05 AM
  2. Macro Required for attaching a file through Browse option in excel file
    By vikash200418 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-18-2015, 12:38 AM
  3. Dropdown Option Coding
    By balilewis in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-14-2015, 08:13 PM
  4. Pivot tables do not renew its data base
    By lmenendez in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-11-2015, 02:25 PM
  5. How to Write a Macro for set a expiry date for Excel 2007 File
    By jobseeker in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-26-2014, 11:07 AM
  6. Coding for Option Buttons
    By Jazzzbo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-22-2013, 08:23 PM
  7. PDF File Convert in Excel by the VBA coding
    By vansh in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-18-2013, 01:42 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