By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,387 Members | 1,729 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,387 IT Pros & Developers. It's quick & easy.

Calling Python Script from MS Excel?

P: n/a
Hi Group -

I have written a "semi-program" in MS Excel related to running a football
pool. I've updated it over the past two years or so, to the point where it
is getting pretty advanced. Only, there are a few tricks that I want to
add that I could not do in Excel - so I did them in Python :) Except as it
stands, the current python scripts have to be run via the command line.
Does anyone know how to allow interaction between Excel and Python via
EXCEL?

I've looked on Mark Hammond's page, and I've figured out how to interact
with Python and Excel from PYTHON, but I can't seem to find the right info
for making the calls from the other end (i.e. from Excel). Any advice
would be GREATLY appreciated!

PS - If anyone has any interest in this type of program, please let me know
- I'd be more than willing to release via the GPL or something to that
effect. Thanks Again...
Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Mon, 07 Jun 2004 21:14:49 -0400, "Kevin T. Ryan"
<ke*********@yahoo.com> wrote:
Hi Group -

I have written a "semi-program" in MS Excel related to running a football
pool. I've updated it over the past two years or so, to the point where it
is getting pretty advanced. Only, there are a few tricks that I want to
add that I could not do in Excel - so I did them in Python :) Except as it
stands, the current python scripts have to be run via the command line.
Does anyone know how to allow interaction between Excel and Python via
EXCEL?

I've looked on Mark Hammond's page, and I've figured out how to interact
with Python and Excel from PYTHON, but I can't seem to find the right info
for making the calls from the other end (i.e. from Excel). Any advice
would be GREATLY appreciated!

PS - If anyone has any interest in this type of program, please let me know
- I'd be more than willing to release via the GPL or something to that
effect. Thanks Again...
You can use COM to go both ways. Just create a COM server in Python
and register it so that Excel can find it.

Check out "Quick Start to Server side COM and Python" in the win32
documents.

You will have to write a little VBScript on the excel side to
interface, I think.
<{{{*>


Jul 18 '05 #2

P: n/a
"Kevin T. Ryan" <ke*********@yahoo.com> wrote in message news:<40**********************@news.rcn.com>...
Hi Group -

I have written a "semi-program" in MS Excel related to running a football
pool. I've updated it over the past two years or so, to the point where it
is getting pretty advanced. Only, there are a few tricks that I want to
add that I could not do in Excel - so I did them in Python :) Except as it
stands, the current python scripts have to be run via the command line.
Does anyone know how to allow interaction between Excel and Python via
EXCEL?

I've looked on Mark Hammond's page, and I've figured out how to interact
with Python and Excel from PYTHON, but I can't seem to find the right info
for making the calls from the other end (i.e. from Excel). Any advice
would be GREATLY appreciated!


One way of approaching this would be to package your Python code
as a COM server. This is actually much easier than you might think
(this reference is quite old but is still relevant):

http://www.python.org/windows/win32c...ServerCom.html

You can make calls on your object from Excel VBA. For example you
could call on the object in the reference above as:

Dim HelloWorld As Object

Set HelloWorld = CreateObject("testcomserver.HelloWorld")
MsgBox HelloWorld.Hello("Kevin")

Hth,
Giles
Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.