Excell spreadsheets

  • Thread starter Thread starter Alan Bunn
  • Start date Start date
A

Alan Bunn

I want to place a "time bar" on an excell spreadsheet so
that at the end of, say, six months, the person will not
be able to gain acces to it.

Step by step instructions would be appreciated.
Thanks.
 
Hi,
The problem with any restrictions you put on the file in
question is that the user may always just open the file
with the "Macros Disabled", and then any restrictions you
put on become redundant. There may be a way to do this
more efficiently, but the only way i've been able to
achieve this is as follows.

The principle is this:
password protect the file to which you want to restrict
access.
Create a temp excel file, which will contain code to open
the password protected file if certain conditions are met,
e.g. x time has not elapsed! (this is the file the user
will actually open)
protect the VBA project in this temp excel file.

If the user disables the macros then the code will never
run, and hence the desired file will never be opened. If
macros are enabled, then the code will run, perform the
time elapsed check and if ok will then open the desired
file.

To do this:
Create a new file, this file will contain nothing except
VBA code. In the "ThisWorkbook" section in VBE use the
following code.
note: you must hardcode in the "staticdate", this is quite
a drawback, but i've found no other way around it.

Private sub Workbook_Open()
Dim staticdate as date
staticdate = #04/26/2003#
if vba.Now - staticdate <60 then

Workbooks.Open Filename:="c:\fullpath\filename.xls",
password:="newpassword"

else
msgbox "License has Expired!"
endif
ThisWorkbook.Close
End Sub

In this example code, the desired file would never be
opened because it is more than 60 days since the 26th Apr.
I have european time setting on my PC but you'll notice
that i still have to specify the staticdate in US format.

Ensure to password protect the VBA project in the launch
file.

Regards,
John,
Ireland.
 
You could also use the Change event to trigger a test for
time. But this may add an unacceptable overhead to the
calculation of the worksheet.
 
Back
Top