title: Excel VBA - Prevent Editing after Date and Force Enable Macros
body: <p>So I have a Workbook that I want to make read-only/protect after a certain date.  I also want to force the user to have macros enabled.  So far I have the following script, but despite changing it to read-only it doesn't seem to do anything.  I have also tried to enable protection on the sheets after that date, but am getting errors.  Can anyone help me out?</p>
  
  <p>-Eric</p>
  
  <pre><code>Private Const ExpirationDate As Date = #4/5/2099#
  
  Private Sub Workbook_Open()
      ' Timebomb
      If CDate(Now) &gt;= CDate(ExpirationDate) Then
          ThisWorkbook.ChangeFileAccess (xlReadOnly)
          ThisWorkbook.Worksheets("Sheet").Protect Password:="NoAccess", UserInterfaceOnly:=True
          ThisWorkbook.Protect Password:="NoAccess", UserInterfaceOnly := True
      End If
  
      ' Force Enable Macros
      ThisWorkbook.Worksheets("Sheet").Visible = xlSheetVisible
      Sheets("START").Visible = xlVeryHidden
  
      ThisWorkbook.Worksheets("Sheet").Activate
  End Sub
  
  ' Force Enable Macros
  Private Sub Workbook_BeforeClose(Cancel As Boolean)
      Sheets("START").Visible = xlSheetVisible
      ThisWorkbook.Worksheets("Sheet").Visible = xlVeryHidden
      ActiveWorkbook.Save
  End Sub
  </code></pre>