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

First, VBA is the "language" for writing code. VBA is
Visual Basic for Applications. The word macro is a
hangover from the early days of spreadsheets when macro
code was actually just keystrokes. When writing code one
uses subroutines ... also known as procedures and macros.

Excel has two methods that the code writer can use to
automatically run code when the wrkbook is opened.
One is to use the Workbook.Open method and the other is
to use a procedure ( aka sub) called Auto_Open
Both will run on opening the workbook.

If you want to secure the workbook, then I'd suggest that
you have one worksheet to use as a "splash screen" and
have all the others set to XlSheetVeryHidden.
Your code can test the date and set the sheets to visible
if the date test succeeds.

This is because if the user sets excel security to haign,
he can open a workbook with macros disabled...in
otherwords your code won't run, but the sheets will be
visible. So by hiding the sheets and only allowing code
to make them visible gives you some protection.

If you're used to VBScript, then you'll find VBA quite
simple. Suggest you turn on hte macro recorder, hide &
unhide some sheets, then examine the code wirtten. It
won't be ideal, but will give you a good handle.


HTH
Patrick Molloy
Microsoft Excel MVP




-----Original Message-----
I want to program (macro or VB script - I'm not sure

which) whenever I open a specific workbook file. I am
very experienced in most functions of excel but have
never "programmed" in it (i.e., macros or VB script -
which do I use). I need some initial guidance to get me
started in how to program the following task...

DESCRIPTION OF TASK TO ACCOMPLISH: I want the workbook

file to be usable only during a certian trial period.
So, when that workbook is opened I want the program to
check if the current date is less than the expiration
date (stored in a hidden cell) and greater than the most
recent used date/time (stored in another hidden cell that
is updated by the program each time the file is opened).

Thanks in Advance,
Warren
.