473,508 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling Python Script from MS Excel?

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
2 3272
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
35484
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet...
1
6982
by: Aaron | last post by:
I am trying to write a Python script file which analyses data in an iterative manner. During each iteration, I wish to utilise the Solver function in Excel to perform some constrained, non-linear...
12
7252
by: guy lateur | last post by:
Hi all, I am trying to write some code (macro's, if you like) to glue together our Office applications (mainly Word, Excel and Outlook). We have a lot of different projects going on...
6
3561
by: Wolfgang Keller | last post by:
Hello, I'm looking for a spreadsheet application (MacOS X prefered, but Windows, Linux ar available as well) with support for Python scripting (third-party "plug-ins" are ok) and a database...
5
2553
by: Shuaib | last post by:
Hi! I have a python script which returns an Integer value. How do I call this script from a C programe, and use the result returned? Thanks for your time.
3
3984
by: dan_roman | last post by:
Hi, I developed a script with a nice interface in Tkinter that allows me to edit some formulas and to generate an Excel worksheet with VBA macros within it. The script runs perfectlly in Office...
4
7927
by: michael.pearmain | last post by:
Hi Experts, Looking for a very quick bit on of advice on how to make some python code run. I'm a newbie to both VBA and Python, so i apologise if this is very easy but i'm about to tear my hair...
3
2066
by: Anthony Smith | last post by:
In my php page I am calling a Python cgi. The problem is that originally the Python script was being called directly and it could access the environment variables that were being set. Now since the...
19
2755
by: John Salerno | last post by:
Hey all. Just thought I'd ask a general question for my own interest. Every time I think of something I might do in Python, it usually involves creating a GUI interface, so I was wondering what kind...
0
7226
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7328
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7388
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7049
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7499
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5631
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4709
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3199
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3186
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.