Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Excel calling tcl script?

443 views
Skip to first unread message

Glennh

unread,
Nov 4, 2004, 12:25:28 PM11/4/04
to
Hi folks,

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

Cameron Laird

unread,
Nov 4, 2004, 3:08:03 PM11/4/04
to
In article <1099589129.sUq8NNQy+qDna96kwJayrA@teranews>,
.
.
.
I do a fair amount of this, Glenn, as do several others. Yes,
it absolutely is feasible.

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?

GlennH

unread,
Nov 4, 2004, 3:35:36 PM11/4/04
to

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

Cameron Laird

unread,
Nov 5, 2004, 9:08:13 AM11/5/04
to
In article <1099600536.kKvR/0Vg+N30fn9bRviowA@teranews>,
.
.
.
I'm getting more of the picture. Are you familiar already with
creation of graphical controls and macros bound to them? At
that level, I know of no practical way to get around reliance
on VBA, although I suspect both that it's actually possible,
and that *that* use doesn't matter to you. The essential outcome,
though, is that you write a macro to
launch your_process.tcl
wait for finish
read summary.html
I'm suggesting that you touch up your_process.tcl to emit HTML
with your data in a <table>; I've had good success lately feed-
ing Excel that way. Is there a part of this where you need more
detail?

Dave Bigelow

unread,
Nov 5, 2004, 1:59:00 PM11/5/04
to
Look at the Ms-Excel Object Browser for a VB-Call to externally launch
an application. It should be there - I would be shocked if it was not
possible. It is probaly a COM interface call.

Dave

Cameron Laird

unread,
Nov 5, 2004, 3:08:05 PM11/5/04
to
In article <e45f1db4.04110...@posting.google.com>,

Traditional, I think, is

ApplicationID = Shell("my_application.exe", vbNormalFocus)
AppActivate ApplicationID
...

Cameron Laird

unread,
Nov 5, 2004, 3:08:04 PM11/5/04
to
.
.
.
See the bottom of <URL: http://wiki.tcl.tk/excel > for more tips.

GlennH

unread,
Nov 7, 2004, 11:21:49 AM11/7/04
to
Thanks Cameron et all - I have this working now - and obviously now I
want more :-)

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

Cameron Laird

unread,
Nov 7, 2004, 3:08:07 PM11/7/04
to
In article <1099844506.uOzrHfdYE0jHvPhB4H61Qw@teranews>,

GlennH <gl...@glennh.com> wrote:
>Thanks Cameron et all - I have this working now - and obviously now I
>want more :-)
>
>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.
.
.
.
No! It's easier than that.

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.

GlennH

unread,
Nov 8, 2004, 3:39:42 PM11/8/04
to
Hi again Cameron, Thanks for that link - I was quite impressed at how
easy it was to get the excel example to work.

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

Cameron Laird

unread,
Nov 9, 2004, 10:09:22 AM11/9/04
to
In article <1099946384.UKed7b1Fb75t6s7qys+oLA@teranews>,

GlennH <gl...@glennh.com> wrote:
>Hi again Cameron, Thanks for that link - I was quite impressed at how
>easy it was to get the excel example to work.
>
>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
.
.
.
Lots of thoughts--more than I can capture until other commitments
slack off.

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.

Tom Krehbiel

unread,
Nov 9, 2004, 10:53:40 AM11/9/04
to
cla...@lairds.us (Cameron Laird) wrote in message news:<8j9262-...@lairds.us>...

> In article <1099844506.uOzrHfdYE0jHvPhB4H61Qw@teranews>,
> GlennH <gl...@glennh.com> wrote:
> >Thanks Cameron et all - I have this working now - and obviously now I
> >want more :-)
> >
> >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.
> .
> .
> .
> No! It's easier than that.
>
> First, congratulations on your progress. I insist
> that you share your results--your working code, or
> a simplification of it--when you can.

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

GlennH

unread,
Nov 9, 2004, 6:18:21 PM11/9/04
to

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

GlennH

unread,
Nov 12, 2004, 2:55:24 PM11/12/04
to
Hi folks.

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

0 new messages