#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 211
Default Time limit

Hi...

Is it possible to code a macro so that a file won't open after a certain date?

Cheers

Gordon...
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Time limit

Hi, put this code in the ThisWorkbook module:

Private Sub Workbook_Open()
If DateValue(Now()) DateValue("29/09/2008") Then ThisWorkbook.Close
False
End Sub

Change the "29/09/2008" to whatever date you want.

The False after the ThisWorkbook.Close is to save the changes.

Hope this helps.


On 29 Sep, 14:35, Gordon wrote:
Hi...

Is it possible to code a macro so that a file won't open after a certain date?

Cheers

Gordon...


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Time limit

You can also control it within the macro with an If ... Then statement:

Sub myMacro()
If Date = DateValue("October 1, 2008") Then
Exit Sub
End If
'myMacro Code
End Sub


"Gordon" wrote:

Hi...

Is it possible to code a macro so that a file won't open after a certain date?

Cheers

Gordon...

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Time limit

Gordon,

It's extremely unlikely that any VB method would deter even a slightly
experienced user or a novice with access to Google. Both of replies you have
require macros enabled and if they aren't enable then the code doesn't
execute and the workbook opens.

Have a look at Chip Pearson's site who explores the problem in some depth
and points aout the shortcomings of any VB approach.

http://www.cpearson.com/excel/WorkbookTimeBomb.aspx

Mike

"Gordon" wrote:

Hi...

Is it possible to code a macro so that a file won't open after a certain date?

Cheers

Gordon...

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
limit on [h]:mm time format? Stefi Excel Discussion (Misc queries) 14 February 22nd 07 10:30 AM
Time limit restriction. ed Excel Programming 4 October 31st 06 07:47 PM
macro to time limit workbook ditchy Excel Discussion (Misc queries) 5 April 26th 05 08:43 AM
set time limit before closing sheet Maria Johansson Excel Programming 2 October 14th 03 08:00 AM
Excel solver time limit David Excel Programming 1 August 7th 03 12:58 AM


All times are GMT +1. The time now is 11:18 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"