View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Warren Warren is offline
external usenet poster
 
Posts: 7
Default Execute program (macro?) upon opening a workbook

Thanks Nicky. I will try what you recommend
The reason I want to record the last used date and check against it is to secure against people temporarily setting back the date on their computer
-Warre

----- Nicky wrote: ----

H
you will need to run a macro on opening, and also one on closing tha
saves the file automatically if you want to record the time of the mos
recent access (though I'm not sure why - won't the time now always b
after the time the file was last accessed?).

the auto-open and auto_close macros run automatically whenever the fil
opens and closes. The attached sheet includes a sort of worked example
with the sheet named "hid" containing data you would hide, and th
macros running to check dates on opening, then closing if the expir
date has passed unless the correct passwor "excelforum" is entered

The macros are

Sub AUTO_OPEN(
If Date Sheets("hid").Range("expiry_date").Value The
resp = InputBox("sorry, your trial has expired." & Chr(10) & "You mus
enter a password to continue working in this workbooket", "Ente
password", resp
If LCase(resp) < LCase(Sheets("hid").Range("password").Value) The
ActiveWorkbook.Clos
End I
End Su

Sub AUTO_Close(
Sheets("hid").Range("last_opened").Value = Now(
Sheets("hid").Range("times_opened").Value = 1
Sheets("hid").Range("times_opened").Valu
If ActiveWorkbook.Saved = False Then ActiveWorkbook.Sav
End Su

Attachment filename: test.xls
Download attachment: http://www.excelforum.com/attachment.php?postid=44732
--
Message posted from http://www.ExcelForum.com