Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Auto-delete the workbook on expiry

Hi

I'm sending out a time-restricted Excel workbook for others to use, and I'd like the file to auto-delete itself if it's already expired. Is this possible to do in VBA? For example, if it's possible, the code could reside in the Workbook_Open event, where a msgbox will pop up to tell the user the file's expired (done), and then delete the file

Thanks heaps for your help

SuperJas.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default Auto-delete the workbook on expiry

Yes that can be done, but very easy to get around, what if they open the
book with macros disabled?

--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2000 & 97
** remove news from my email address to reply by email **
"SuperJas" wrote in message
...
Hi,

I'm sending out a time-restricted Excel workbook for others to use, and

I'd like the file to auto-delete itself if it's already expired. Is this
possible to do in VBA? For example, if it's possible, the code could reside
in the Workbook_Open event, where a msgbox will pop up to tell the user the
file's expired (done), and then delete the file.

Thanks heaps for your help,

SuperJas.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Auto-delete the workbook on expiry

Hi Paul

That isn't a problem, as they wouldn't know that the macro would do that...until the file's disappeared. These recipients have elementary macro exposure

Could you please show me how to do it

Thanks

SuperJas

----- Paul B wrote: ----

Yes that can be done, but very easy to get around, what if they open th
book with macros disabled

--
Paul B
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Auto-delete the workbook on expiry

Deleting a workbook without letting the user know that is a posibility would
be identical to infecting them with a virus.

Definitely would not make you any sales.

--
Regards,
Tom Ogilvy

SuperJas wrote in message
...
Hi Paul,

That isn't a problem, as they wouldn't know that the macro would do

that...until the file's disappeared. These recipients have elementary macro
exposure.

Could you please show me how to do it?

Thanks,

SuperJas.

----- Paul B wrote: -----

Yes that can be done, but very easy to get around, what if they open

the
book with macros disabled?

--
Paul B



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Auto-delete the workbook on expiry

Hi Tom

Haha! =) No fear, the file's being sent out to internal staff for their use. We wish to delete the file so that we'll be sure that they use the most updated version available

Thanks

SuperJas.


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default Auto-delete the workbook on expiry

SuperJas, You are assuming that they don't have a backup copy of the file
that they can open with macros disabled, always back up your work!. I don't
think it would be a good idea to just kill the fill without them knowing
about it. How about something like this, it will give them a message box
when the fill is opened and if the date has passed it will delete it on
close. Or you could use the macro at the bottom, that I got off of this
newsgroup, to pause the sheet on open, will pause for 1 Minute for everyday
past expiration date. Again this and most things you can do for and
expiration date can be disabled, but maybe it will work for you. You can
also password protect the VBA to make it a little harder to get around, but
not much. Put this code in the thisworkbook code


Private Sub Workbook_Open()
MsgBox "This file will expire on 2-20-2004"
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Date = #2/20/2004# Then
ThisWorkbook.Saved = True
MsgBox "This file has expired, it will be deleted!"
ThisWorkbook.ChangeFileAccess xlReadOnly
Kill ThisWorkbook.FullName
End If
End Sub

Or use this

Private Sub Workbook_Open()
'program will pause for 1 Minute for everyday past expiration date
'can also be used in before save, worksheet Activate,
'Worksheet_SelectionChange, etc
Dim myCutOff As Long
myCutOff = DateSerial(2004, 2, 20)
If Date myCutOff Then
MsgBox "I'm sorry, this workbook should have expired on: " _
& Format(myCutOff, "mm/dd/yyyy") & vbLf & _
"After you dismiss this box, this program will pause for: "
_
& CLng(Date) - myCutOff & " Minutes!" & vbLf & vbLf & _
"One Minute for each day past expiration!"
Application.Wait TimeSerial(Hour(Now), Minute(Now) +
CLng(Date) - myCutOff, _
Second(Now))
End If
End Sub


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2000 & 97
** remove news from my email address to reply by email **
"SuperJas" wrote in message
...
Hi Paul,

That isn't a problem, as they wouldn't know that the macro would do

that...until the file's disappeared. These recipients have elementary macro
exposure.

Could you please show me how to do it?

Thanks,

SuperJas.

----- Paul B wrote: -----

Yes that can be done, but very easy to get around, what if they open

the
book with macros disabled?

--
Paul B



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Auto-delete the workbook on expiry

Hi Paul

Thanks! I quite like the pausing idea- I'll give it a whirl

SuperJas.
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default Auto-delete the workbook on expiry

SuperJas, if you like that and the time is to long, this one will pause for
1 second for everyday past expiration date

Private Sub Workbook_Open()
'program will pause for 1 second for everyday past expiration date
'can also be used in before save, worksheet Activate,
'Worksheet_SelectionChange, etc
Dim myCutOff As Long
myCutOff = DateSerial(2004, 2, 7)
If Date myCutOff Then
MsgBox "I'm sorry, this workbook should have expired on: " _
& Format(myCutOff, "mm/dd/yyyy") & vbLf & _
"After you dismiss this box, this program will pause for: "
_
& CLng(Date) - myCutOff & " seconds!" & vbLf & vbLf & _
"One second for each day past expiration!"
Application.Wait TimeSerial(Hour(Now), Minute(Now), _
Second(Now) + CLng(Date) - myCutOff)
End If
End Sub


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2000 & 97
** remove news from my email address to reply by email **
"SuperJas" wrote in message
...
Hi Paul,

Thanks! I quite like the pausing idea- I'll give it a whirl.

SuperJas.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Expiry of Excel Sheet or WorkBook Hardeep kanwar Excel Worksheet Functions 1 March 30th 09 07:26 AM
Macro - Auto - Sheet Name change ? expiry Som Excel Discussion (Misc queries) 3 March 21st 09 03:39 AM
Auto deletion of excel file after a certain date - expiry Som Excel Discussion (Misc queries) 7 March 20th 09 09:59 AM
Sometimes formuli in workbook don't auto update with auto-recal on PE2 Excel Worksheet Functions 1 October 12th 06 03:49 PM
How to Delete a Range in Closed Workbook (to Replace Delete Query) [email protected] Excel Discussion (Misc queries) 1 March 8th 06 10:10 AM


All times are GMT +1. The time now is 11:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"