Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Schedule a Macro to Run

Status
Not open for further replies.

JulieS

MIS
Nov 23, 2000
48
CA
How do you setup a macro to run at a certain time everyday without being manually started?

Thanks,
Julie
 
Hi JulieS!

I think you won't get this done without some programming work. I guess you can do this with VBA.
Try it with an endless-loop which does time-checking the whole time. If the time equals your starting-time you can perform the macro by calling it. But therefore your office application has to be open the whole day till the macro ran!

I don't know if this is what you want?!

cya

frag patrick.metz@epost.de
 
Julie,
Here is some info on the OnTime Procedure from the Excel vba help. It should make it fairly easy to accomplish what you want. You probably want to add it in the workbook_open event of the workbook with the macro. It is a method of the Application object so 'expression' in this help file would just be Application

Code:
Application.OnTime TimeValue("17:00:00"), "MacroName"

would schedule a macro called MacroName to run at 5pm.

Code:
Schedules a procedure to be run at a specified time in the future (either at a specific time of day or after a specific amount of time has passed).

Syntax

expression.OnTime(EarliestTime, Procedure, LatestTime, Schedule)

expression   Required. An expression that returns an Application object.

EarliestTime   Required Variant. The time when you want this procedure to be run.

Procedure   Required String. The name of the procedure to be run.

LatestTime   Optional Variant. The latest time at which the procedure can be run. For example, if LatestTime is set to EarliestTime + 30 and Microsoft Excel is not in Ready, Copy, Cut, or Find mode at EarliestTime because another procedure is running, Microsoft Excel will wait 30 seconds for the first procedure to complete. If Microsoft Excel is not in Ready mode within 30 seconds, the procedure won't be run. If this argument is omitted, Microsoft Excel will wait until the procedure can be run.

Schedule   Optional Variant. True to schedule a new OnTime procedure. False to clear a previously set procedure. The default value is True.

Remarks

Use Now + TimeValue(time) to schedule something to be run when a specific amount of time (counting from now) has elapsed. Use TimeValue(time) to schedule something to be run a specific time.
Ruairi
ruairi@logsoftware.com
Experienced with:

VB6, SQL Server, QBASIC, C(unix), MS Office VBA solutions

ALSO: Machine Control/Automation using GE and Omron PLC's and HMI(human machine interface) for industrial applications
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top