Run macro with Windows Task Scheduler

Noz2k

Well-known Member
Joined
Mar 15, 2011
Messages
693
Currently I have a task setup which opens my workbook every day at a set time, runs 2 macros in the workbook open procedure and then closes excel.

However as the macros email people, having the code run on the workbook open procedure is not ideal. If the file is opened at any other time these emails will still be sent, which will just confuse people (it also makes it a pain to edit as the procedure closes the workbook.)

Is there a way to use the task scheduler to run specific Macros so I wouldn't have to have them in the workbook open procedure?
 
Last edited:
Running Excel 2007, OS = Vista
Create a .vbs file and run from Task Manager

Code:
Dim oExcel
Set oExcel = WScript.CreateObject("Excel.Application")
oExcel.Visible = True
oExcel.Workbooks.Open "C:\MyPath\MyProgram.xlsm"
oExcel.Run "'MyProgram.xlsm'!Main"
oExcel.workbooks("MyProgram.xlsm").Close False
oExcel.Quit
Set oExcel = Nothing
 
Upvote 0

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,214,925
Messages
6,122,303
Members
449,078
Latest member
nonnakkong

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top