Results 1 to 1 of 1

Not Open Excel File After Fixed Date!

Threaded View

  1. #1
    Forum Contributor
    Join Date
    12-27-2008
    Location
    India
    MS-Off Ver
    Office 365
    Posts
    235

    Post Not Open Excel File After Fixed Date!

    I got a VB code, from our forum. However, want to make modify as per following.

    Currently, If I put to save excel file all other sheets (except sheet 1) are hidden. (before expire)

    I do not want to be hidden until Excel File expires, by his expire in date like here 2009,01,05

    Private Sub Workbook_Open()
        Dim i As Integer
           If Date <= DateSerial(2009, 1, 5) Then
       
            Application.ScreenUpdating = False
            ThisWorkbook.Unprotect Password:="___"
            
            For i = 2 To Worksheets.Count
            
                Worksheets(i).Visible = True
            Next i
            ThisWorkbook.Protect Password:="___"
            
            Application.ScreenUpdating = True
        Else
            MsgBox "This file cannot be accessed after Jan. 05, 2009."
        End If
    End Sub
    
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
        Dim i As Integer
        
        Application.ScreenUpdating = True
        ThisWorkbook.Unprotect Password:="___"
        For i = 2 To Worksheets.Count
        
            Worksheets(i).Visible = xlVeryHidden
        Next i
        ThisWorkbook.Protect Password:="___"
        Application.ScreenUpdating = True
    End Sub
    Attached Files Attached Files
    Last edited by rr1050; 01-05-2009 at 09:33 AM.

Thread Information

Users Browsing this Thread

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

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