Link to home
Start Free TrialLog in
Avatar of rsen1
rsen1

asked on

VBA to set Excel macro security

Guys, how do I put a code that the security setting will not open my workbook past a given date. I have the code below, but the macro security option still allows the workbook to open if security is set to disable macros. And simply clicking cancel allows the workbook to function.

Private Sub Workbook_Open()
Dim Expire As Date
'Workbook expires on this data and file will be shut down
 Expire = "15-Feb-2012"
 ActiveWorkbook.Close
End Sub

Thank you for your help
Avatar of McOz
McOz

One way is to create another worksheet called "startup" or something, which is just blank.

Hide all other "normal" worksheets, and save it in that state.

Then have your code unhide the sheets (with the Open event) if the expiration date is not reached.

Note: you'll also want to hide them again with the BeforeSave event to prevent a user from saving them in the un-hidden state.

McOz
Avatar of rsen1

ASKER

thank you for your response, is there a way to set the security such as Application.FixedDecimal = True,
except state "application.security= enable''
or something like that
SOLUTION
Avatar of Shanan212
Shanan212
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rsen1

ASKER

Thank you Guys