Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Scheduled Task

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.


  #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.


.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Scheduled Task

Thanks Tod, I'll take your advice. When I run the VB Script, my Main
function currently displays a message box. But the Excel doesn't show up on
the task bar anywhere. Is that normal?

Any recommendation on anything else?

cheers,
Matt.

"Tod" wrote in message
...
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.


.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Scheduled Task

This seemed to do it. But Book 1 still opens (after the file.....).

"C:\Program Files\Microsoft Office\Office\EXCEL.EXE" /e c:\test.xls

cheers,
Matt
"Matt." wrote in 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.




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

Don't use the task scheduler to open Excel. Instead, give
it the path of the vbscript. The script code will open the
your workbook. Your OS is configured to open Excel by
default.

tod

-----Original Message-----
This seemed to do it. But Book 1 still opens (after the

file.....).

"C:\Program Files\Microsoft Office\Office\EXCEL.EXE" /e

c:\test.xls

cheers,
Matt
"Matt." wrote in

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.




.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how many people are scheduled between... jat Excel Worksheet Functions 0 October 22nd 09 10:39 PM
After Windows update scheduled task uses wrong version of Excel CharlesW Excel Discussion (Misc queries) 0 July 15th 09 04:53 PM
Run Excel macro from Scheduled Task coolthinking Excel Worksheet Functions 4 July 13th 09 03:35 PM
Trying to run a MSQuery from Excel as a Scheduled Task Doug Excel Discussion (Misc queries) 1 March 6th 09 06:01 PM
Pivot Table through Scheduled Task [email protected] Excel Discussion (Misc queries) 1 October 18th 05 09:27 AM


All times are GMT +1. The time now is 05:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"