Scheduling a Macro to Run

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I know that i can set up Windows to run Excel at a certain time everyday or
week or what ever. I am wondering if there is a way to schedule excel to
open a file and execute a macro at a certain time each week.

Thanks,

Tim
 
You can have windows open the excel file and have a macro in that excel
file that executes upon openning:

Private Sub Workbook_Open()

End Sub
 
the workbook_Open event will fire when a workbook is opened, so put your code
in the workbook_open event and use the windows scheduler to have excel open
and open the workbook

Excel.Exe "C:\MyFolder\Myfile.xls"

runs excel and opens Myfile.xls

http://www.cpearson.com/excel/events.htm
 
I would like to schedule the event to run at about 4:00 am. How can i have
it set up to run automatically if the time is between 4am and 5 am and run
manually if it is any other time? I just made up this code but it obviously
doesn't work

Sub Workbook_Open()
If Time > 3 and Time < 5 Then Call CommandButton1_Click
Else
End Sub


CommandButton1_Click is the Sub that runs the program
 
I would like to schedule the event to run at about 4:00 am. How can i have
it set up to run automatically if the time is between 4am and 5 am and run
manually if it is any other time? I just made up this code but it obviously
doesn't work

Sub Workbook_Open()
If Time > 3 and Time < 5 Then Call CommandButton1_Click
Else
End Sub


CommandButton1_Click is the Sub that runs the program
 
Sub Workbook_Open()
If Time > TimeSerial(3,0,0) and Time < TimeSerial(5,0,0) Then
MyMacro
End if
End Sub

? timeserial(3,0,0)
3:00:00 AM

I would put the code in a general module and have the commandbutton call
that macro as well.

Private Sub commandButton1_click()
MyMacro
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top