Thread: Scheduled Task
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
tod tod is offline
external usenet poster
 
Posts: 114
Default Scheduled Task

You can create a vbscript and point the scheduled task to
that script. Here's an example of a script that opens a
workbook, runs a procedure in the workbook called Main,
then closes the workbook.

Dim xl
Dim CurrentBook

Set xl = CreateObject("Excel.Application")
Set CurrentBook = xl.Workbooks.Open
("C:\MyPath\BookName.xls")
xl.Run "Main"
CurrentBook.Save
CurrentBook.Close
xl.Quit

set CurrentBook = nothing
set xl = nothing

tod
-----Original Message-----
Hi all!

I would like to use the Task Scheduler to open a specific

Excel File. Can
somebody give me a sample of the correct syntax? And

prevent it from
opening Book 1, too?

The reason? I need to schedule a periodic query of a SQL

Server database,
read the data into Excel, save the spreadsheet with a

unique name everyday,
and then email the resultant spreadsheet to a list of

people, and then close
the Excel spreadsheet, and exit Excel. I know how to do

most of the above
with VBA, but I can't get the syntax right for the

scheduler. I haven't
actually started the programming for this yet. If

somebody has some tips to
performing this task, I would greatly appreciate it.

cheers,
Matt.


.