Hi, I have a macro run when a workbook opens.

I have just moved it to perform automatic run when the book opens but I get a "complie error" highlighting the me.visible part of the code.

Anyone with any idea's why the code isn't working?

Incidentally, r1 is the current date, and s1 is a preset date - so I need the message box to alert once the current date (r1) has passed teh set date (s1)


Private Sub Workbook_Open()

1 If [r1] > [s1] Then
2 x = MsgBox("Please upgrade", vbOKCancel, "TRIAL EXPIRED")
3 If x = vbCancel Then
ActiveSheet.Unprotect
Cells.Select
    Range("G3").Activate
    Selection.ClearContents
    Selection.Delete Shift:=xlUp
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowFiltering:=True
End If
4  Dim Reply As String
On Error GoTo Reset
Application.EnableEvents = False
Me.Visible = xlSheetVeryHidden
Reply = InputBox("Please enter the password.")
If Reply = "********" Then
Me.Visible = xlSheetVisible
Sheets("Main").Select
 Else
  Me.Visible = xlSheetVeryHidden
   Me.Select
End If
Reset:
Application.EnableEvents = True




End If
5 End Sub