PDA

View Full Version : VBA Excel: How to create file which will be crashed on precise date



junior_88
12-03-2014, 01:45 PM
How to create file which will be crashed on precise date e.g 01.03.2015. I wish that this date it will be not possible to use file.Is it possible ? Is there any function to do this ?

GTO
12-03-2014, 09:43 PM
Sesarch the KB for "expiration" I seem to recall. Whilst it requires the user to allow code to run, you can either slef-delete a workbook, or simply make it un-editable. That said, any efforts in this manner should simply be looked at as providing an inconvenience-level deterence.

Hope that helps,

Mark

SamT
12-03-2014, 09:49 PM
Private Sub Workbook_Open()
With Application
.ScreenUpdating = False
.DisplayAlerts = False 'Important!
End With

If Date >= CDate("01/ 03/2015") Then
'Delete all important Sheets. Be sure to leave one sheet.
'Alternately, be sneaky, copy all cells on sheet and PasteSpecial.Values back to sheet. Repeat per sheet.

Me.Save
End If

With Application
.ScreenUpdating = True
.DisplayAlerts = True
End With
End Sub

snb
12-04-2014, 12:26 AM
Save yourself the effort: if macros have been disabled nothing will be deleted at all.
With a proper backup procedure the file of the previous day can be opened and modified.

junior_88
12-04-2014, 02:29 AM
The macro will be deleted but also I will protect entire file by password. I think this issue will solve problem.

If I look, I give info is it works.

GTO
12-04-2014, 03:59 AM
Save yourself the effort: if macros have been disabled nothing will be deleted at all.
With a proper backup procedure the file of the previous day can be opened and modified.

As mentioned, "protection" is simply 'closing the gate to the back yard' (with nary even a padlock in sight). You can still open the gate and walk in, or jump the fence...

That said, opening the file without code enabled can certainly be handled by eliminating a saved state from occurring with any sheet of worth visible.

The previous day's file I presume to mean a file that hasn't had the code run prior. Interesting point :-) Describe: "With a proper backup procedure..."

Mark

SamT
12-04-2014, 08:51 AM
Gentlemen and ladies, let us not forget that we here at VBAX are the Masters of the MS Office Universe.


Mere Mortals cannot even imagine the things we can do in our U-neee-verrrrrrrrrrrrrse! :devil2: Buwah-hahahaha.



Even though attempts at protecting Excel are only like putting a snap-link through the hasp on the gate, it still keeps the toddler in the yard, and 99.99% of Users are toddlers in a VBA nursery, so to speak.

Blade Hunter
12-04-2014, 05:24 PM
Why not work it the other way, instead of password protecting after expiry, password protect everything up front and have code to unprotect everything on open if the date is prior to your expire date, if the user doesn't enable macros then they simply don't get the data

GTO
12-04-2014, 10:11 PM
...Even though attempts at protecting Excel are only like putting a snap-link through the hasp on the gate, it still keeps the toddler in the yard, and 99.99% of Users are toddlers in a VBA nursery, so to speak.

Kudos Sam; nicely put!


Why not work it the other way, instead of password protecting after expiry, password protect everything up front and have code to unprotect everything on open if the date is prior to your expire date, if the user doesn't enable macros then they simply don't get the data

:bow: Not tried, but sounds slick :thumb