I'm in test automation. We have a test planning / execution spreadsheet
that we update by running a tcl script to summarise all the test results
from multiple results directories and then importing the sumamry into a
database in the spreadsheet.
Currently I have to run the tcl summary script manually (from unix) then
open the spreadsheet and import the summary file.
I want to automate this whole process to a single button click from
excel. Has anyone called a tcl script from excel?
Maybe I could re-code the results summary script in visual basic within
the excel spreadsheet?
Or get the sumamry script to open the spreadsheet and update the database?
Any thoughts?
thanks
Glenn
I think I might be misinterpreting "importing the summary into a
database in the spreadsheet." When you write, "database", do you
have in mind a persistent score *other* than Excel's native one?
Let me repeat a few of your words. It sounds as though you want
to create a button within Excel, hosted on Windows machine A, whose
action is to run a Unix process on machine B, create a summary, and
import that summary back into the Excel spreadsheet on A. Do I
have that right?
Hi Cameron,
Yes, that's right, however because I have a shared file system I can
probably run the tcl script on the windows machine too. (I just happen
to be doing that on the unix machine at the moment becuae thats the
current process.
The database is within Excel.
Glenn
Dave
Traditional, I think, is
ApplicationID = Shell("my_application.exe", vbNormalFocus)
AppActivate ApplicationID
...
I not want to read the values of two cells and pass the values to my tcl
script. Need to learn sone more Excel VBA I guess.
Glenn
First, congratulations on your progress. I insist
that you share your results--your working code, or
a simplification of it--when you can.
Next, you don't have to think VBA at all to share
data between Excel and Tcl. <URL:
http://wiki.tcl.tk/tcom > has details. Do you see
how to do it? Frankly, it's a lot of fun, once you
get the ideas down, and we all owe Chin Huang a big
debt.
However I think I want the Excel spreadsheet to take the lead rather
than the tcl script.
e.g. I want my process to be:
- Open test results spread sheet
-- Test results directory path is in cell A1 (for example)
-- Test results summary file path (output from my tcl script) is in A2
- Click 'update' button.
-- Tcl script is run with parameters from A1 and A2. This updates the
test results summary file.
-- Update external data in Excel worksheet using path from A2 as filename.
- Done
Any thoughts
Glenn
If I understand you correctly, Glenn, your vision starts to blur
at the "Tcl script is run with parameters ..." part. While there
are quite a few different ways to go about this, I think only two
are worth considering, and, unless there are special circumstances,
one is the clear choice for your first attempt:
1. Use Shell("your_TCL_script <parameters>") to
invoke the Tcl process from Excel, with the
values you want to communicate on the com-
mand-line. Tcl will happily retrieve them
from there.
2. If it happened to fit other parts of your
requirements well, you could Shell() with
no additional requirements, but use tcom
to interrogate the Excel spreadsheet.
Do you see which of those you want to pursue? Do you need more
details?
I suspect there's an apt aphorism nearby about engineering having
to do both with knowing technical stuff, and making choices be-
tween alternatives--often in partial ignorance.
FYI - take a look at "Tcom examples for Microsoft Excel"
(http://mini.net/tcl/11900) it may be of some help (at lease that was
my intent).
Tom Krehbiel
My ideal is number 1. I can already call my tcl script with harcoded
parameters for the two parameters - however i want my user to be able to
alter the two parameters - by changing the values of two cells, and to
use the two cell values as the parameters passed to the tcl script.
Probably not too hard but I've not successfully passed the values of the
two cells as parameters to the tcl script.
I would rather avoid tcom if possible simply to have the simplest
solution and hence enable others in my team to easily understand and
maintain the solution.
Glenn
I've been getting on quite well with this.
I have a button in my spreadsheet which runs my tcl script, passing the
contents of two cells as command line arguments to the script.
It waits for the script to finish and collects the return code, stdout
and stderr from the script which allows me to notify my user of success
or failure.
However I do have an interesting problem that I've not got to the bottom
of yet:
My tcl script reads test result files from individual sub-directories of
my results directory and produces a csv format summary file.
This works fine when I run it from the command line however when I run
it from excel the summary file is created but has no data in it.
----
Thanks to everyone for their help. When I have this last problem sorted
out I'll add the work and my experience to the wiki excel page and post
here.
Glenn