how to expire Excel file after certain date

S

Som

after a certain date(date will provided by the user) a password protected MS
excel file will not open with valid password OR the data of the said file
will be erased OR file will be corrupted .In one sentence , after a certain
date(date will provided by the user) a password protected MS excel file will
be destroyed in any form ??? (even if the 2nd line user copies (n number of
copies) the file to their own PCs also from our PC).I require this option for
some copyright / licence issue... Can u please help me?
 
J

Jacob Skaria

Hi Som

You need write a piece of code. From the menu go to
Tools-->Macro-->Visual Basic Editor-->
Select Worksheet and copy the below code

Private Sub Workbook_Open()
If DateDiff("d","12/Mar/2009",Date) < -1 Then
Application.ActiveWorkbook.Close
End If
End Sub

This will only allow the workbook to be used upto Mar 12th. Password protect
the Visual Basic Editor before you distribute.

Jacob Skaria
(If this post is helpful please click Yes)
 
J

Jacob Skaria

Just a clarification.

On disable macro: Cant the user have some functionalities controlled by
scripts. This needs to be enabled only from Workbook_Open(); to make sure
that the user always enables the macros.

On changing dates: In Excel the user can record the last open Date and Time
to VBE.CodePanes of the workbook itself and check aganist that during every
Workbook_Open();

Appreciate your thoughts.........
 
S

Som

No ,

it is not working...!!!!!!

I've given 11 march 2009

but it is openning......!!!!!!

one thing , I want to inform that here in my office by default MS Excel
Macro Security is 'VERY HIGH'.....

is this creating the problem?

*** how to give different password in MS Excel VB editor?
 
B

Bob I

Since 11 March is not greater than today, it is supposed to open. Change
the expire date to yesterday.
 
B

Bill Sharpe

Jacob said:
Hi Som

You need write a piece of code. From the menu go to
Tools-->Macro-->Visual Basic Editor-->
Select Worksheet and copy the below code

Private Sub Workbook_Open()
If DateDiff("d","12/Mar/2009",Date) < -1 Then
Application.ActiveWorkbook.Close
End If
End Sub

This will only allow the workbook to be used upto Mar 12th. Password protect
the Visual Basic Editor before you distribute.

Jacob Skaria
(If this post is helpful please click Yes)

I have a suspicion that if a user were to open the file in
OpenOffice.Org's scalc program the macro would not work. I haven't tried
this particular approach, but I have been able to view protected VBA
code in Excel worksheets opened with scalc.

Excel's password protection is pretty weak.

Bill
 
S

Som

no it failed again in another PC....

because by default in my company , the macro level set very high... so it is
not running in other PCs

msg comnig -- " Macros are disabled because the security level is set very
high. To run the macros , change the security level to a lower setting and
verify the macros are signed & trusted"

, now what to do ??

i cann't change all PC s macro security setting of client location....

so i have to do the job keeping in my mind that " macro security will be
high "

now pls advise
 
S

Som

can u give me a code which will delete the excel file permanently if somebody
tries to open the file after the specified date ?
how to protect the code in the MS VB editor for macro , so that nobody can
see the code before expiry date / deletion date.
 
J

Jacob Skaria

Hi Som

On your query on how to protect macro
User Tools-->VBA Properties-->Protection to protect the macro

If macro security is by default set to high; then there is no point trying
out with macros.

If this post helps click Yes
 
S

Som

dear all,

thanks for your involvement .

now the file is deleting if macro runs ....

1. how protect / encrypt the code.

2. next concern is Macro security is by default HIGH , I cann't give up !!!!
pls help me find out the way..... is there any option that wherever the file
will be openned the Macro security will be changed to LOW ??

3. is there anyother way apart from Macro to do the same?

I need to complete the job

waiting.......
 
G

Gord Dibben

Apparently you used Chip Pearson's TimeBomb code.

Did you read Chip's comments on Excel security?

Only effective to keep "honest" persons from hacking your workbook and its
code.

Read this from Chip's site.........................

All protection mechanisms in Excel are really intended to prevent the user
from accidentally changing a value or some code. The security just isn't
strong enough to provide real protection of proprietary information or
information or code with intellectual property value. For that level of
security, you should be writing your code in Visual Basic 6 or VB.NET. See
Creating A COM Add-In for details about creating a COM Add-In and Automation
Add Ins A Function Libraries for details about creating an Automation
Add-Ins.

Another point.........................

You cannot change a user's macro security settings via code.

If you could, there would be no point in having levels of macro security.


Gord Dibben MS Excel MVP

dear all,

thanks for your involvement .

now the file is deleting if macro runs ....

1. how protect / encrypt the code.

2. next concern is Macro security is by default HIGH , I cann't give up !!!!
pls help me find out the way..... is there any option that wherever the file
will be openned the Macro security will be changed to LOW ??

3. is there anyother way apart from Macro to do the same?

I need to complete the job

waiting.......
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top