473,738 Members | 6,332 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 3284
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
35559
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 utility from my PythonWin (IDE from ActiveSTate),
1
7040
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") .. .. .. self.xlapp.run(macro)
12
7283
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, on a per project basis. As an example, I'd like to have a control (button, menu entry) in Outlook...
6
3584
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
2573
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
4007
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 (only in Excel 2003, in 2000 not): import os
4
7952
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 and how many objects can change for each project i run.
3
2081
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 call the Python script in such a way where it can access those variables? These are the type of...
19
2783
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 at work, if you feel like talking about that! :) Thanks.
0
8968
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9334
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9259
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8208
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6750
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6053
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4569
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4824
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.