473,544 Members | 1,775 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 3275
On Mon, 07 Jun 2004 21:14:49 -0400, "Kevin T. Ryan"
<ke*********@ya hoo.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*********@ya hoo.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("t estcomserver.He lloWorld")
MsgBox HelloWorld.Hell o("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
35496
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 and extract information from specific worksheets and cells. I'm not really sure how to get started with this process. I ran the COM Makepy...
1
6987
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 fitting to the data. I have a VBA macro which runs the Solver, and am using self.xlapp = win32com.client.dynamic.Dispatch("Excel.Application") .....
12
7255
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 simultaneously. The idea is to develop a centralized framework (starting point, common interface) for my users to view/control their documents/correspondence,...
6
3562
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 interface. Applications that I know of (that they exist) are: MS Excel Quattro
5
2556
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
3990
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 2000, but in Office 2003 crash at line: "wbc = workbook.VBProject.VBComponents.Add(1)" Please help me :-( the code of the module that crash is...
4
7931
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 out after googling for the last 3 days. I have written a large python script which inside of it creates an Excel table, the name of this file...
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 php script is being called first it has access to the environment variables, but the Python script does nt. How can I forward the variables or...
19
2757
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 of work you all do with Python that does *not* involve any GUI work. This could be any little scripts you write for your own benefit, or what you do...
0
7416
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7360
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7761
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7363
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5899
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4906
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3403
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3400
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
653
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.