Google Answers Logo
View Question
 
Q: Automating Excel ( No Answer,   7 Comments )
Question  
Subject: Automating Excel
Category: Computers > Software
Asked by: chanelops-ga
List Price: $20.00
Posted: 24 Mar 2005 20:04 PST
Expires: 02 Apr 2005 06:25 PST
Question ID: 500062
I have an add-in to Excel that downloads stock prices and puts them in
a nice spreadsheet.  My question is, how can I set this to run
automatically and download the stock prices each day, and save them in
a file with the date as the name?

I'm thinking I could write a short macro and use Windows Task
Scheduler to start Excel, but then how do I get my macro to start?  (I
use Excel for other things, so I wouldn't want this macro to run every
time I open Excel)

And how do I automatically save each day's spreadsheet to a file
containing the data as part of the file name?
Answer  
There is no answer at this time.

Comments  
Subject: Re: Automating Excel
From: xarqi-ga on 24 Mar 2005 20:22 PST
 
Maybe like this:
Create an excel template document that contains a macro that is
invoked on opening.  It downloads the data, and saves itself under a
name derived from the current date and exits.
Use the task sceduler to run open the template document once per day.
Subject: Re: Automating Excel
From: chanelops-ga on 24 Mar 2005 20:36 PST
 
Xarqui: OK, I like your idea, conceptually.  Now, how do I go about
implementing it?  I'm not an Excel expert, and although I have some
familiarity with it, I've never created an Excel template.

Also, how do I get the macro to save itself under a name derived from
the current date?
Subject: Re: Automating Excel
From: xarqi-ga on 24 Mar 2005 21:06 PST
 
Ummmm - good questions!

The "template" is just an ordinary excel file that will have the
necessary formulae and formatting in it, and contain the Macro that
will run on opening the document:
See here for some pointers: http://www.contextures.com/xlfaqMac.html#Mac04

As the last things the Macro does, it could something like:
http://www.mrexcel.com/tip040.shtml
taking it's name from a cell whose value is derived using the today()
function, or just calculated directly in the macro.  It could then do
an application.quit.
Subject: Re: Automating Excel
From: willcodeforfood-ga on 24 Mar 2005 21:24 PST
 
You can use a batch file to make a copy of the Excel file so that the name
of the file contains the date.  The batch file can then run Excel and open
the new Excel file.  The auto run macro would then fetch your stock quotes
and close Excel.

1) I started with the Excel template document already suggested and put
  it in a folder c:\test and called that document StockQuotes.xls
2) Then in my c:\test folder I created a file called stocks.bat
3) I put these two commands in the stocks.bat file

copy "c:\test\StockQuotes.xls" "c:\test\StockQuotes_%date:/=%.xls"

"C:\Program Files\Office\Office\EXCEL.EXE" "c:\test\StockQuotes_%date:/=%.xls"

4) Then set the Windows Task Scheduler to run c:\test\batch.bat once a day

You'll need to modify the folder and file names in the batch file to get it
to work on your computer.  Your copy of Excel.exe may be in a different 
folder than on my computer.
Subject: Re: Automating Excel
From: willcodeforfood-ga on 24 Mar 2005 21:26 PST
 
Correction:

4) Then set the Windows Task Scheduler to run c:\test\stocks.bat once a day
Subject: Re: Automating Excel
From: chanelops-ga on 25 Mar 2005 05:49 PST
 
Thanks for the suggestions, guys.  Let me see if I can find some time
this weekend to try the various tactics suggested, and I'll let you
know what happens.
Subject: Re: Automating Excel
From: chanelops-ga on 27 Mar 2005 20:24 PST
 
I did not get very far implementing the suggestions, due to a problem
I found: I can't make the macro work to run my Excel add-in.  While
I'm able to record regular macros fine, when I try to record a macro
that goes up to the special toolbar that the add-in has and tries to
run the add-in, for some reason the macro just doesn't get recorded. 
I examined the macro text, and it's just blank.

I am currently investigating another promising approach for obtaining
this data which does not utilize Excel.  Let me see if I can get that
to work.  In the meantime, I'd like to put this question on hold.  If
I can't get the other approach to work, I'll come back here and try to
get past this roadblock I've hit with the non-recording macro.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy