473,795 Members | 3,063 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Separating win32com automation instances?

I am investigating a web-based app wherein I wanted to provide html
form frontends to an Excel spreadsheet sitting on a MS Windows server;
with each authenticated HTTP user having thier own "invisible" copy of
the spreadsheet changeable via form POST via COM automation object
(via Python) - then after recalculating - present the spreadsheet
results in HTML. The whole idea to 1: isolate the user from having to
have Excel, and 2: avoiding rewriting the hundreds of Excel formulas
in a CGI.

HTML FORM -> POST -> Python win32com -> Spreadsheet -> Recalc -> HTML

Now the problem is that win32com.client .Dispatch apparently does not
play well with other Dispatch instances.

If I have two instances of Python running, and Dispatch two instances
of ("Excel.Applica tion"), I find that when I close one workbook, they
are all closed.

eg:
Python instance 1 in DOS window 1:

from win32com.client import Dispatch
x1 = Dispatch("Excel .Application")
x1.workbooks.op en("workbook1.x ls")
Python instance 2 in DOS window 2:

from win32com.client import Dispatch
x2 = Dispatch("Excel .Application")
x2.workbooks.op en("workbook2.x ls")
x2.workbooks.cl ose("workbook2. xls")

Guess what? Closing x2 also closes x1.

How do I get around this? I'm running this test from two DOS prompts.
Also any changes I make using x2 (like switching the sheet) appear in
the x1 instance.

Does DCOM resolve this; is this a failure with Excel; or is it how
win32com works; or is it just a COM problem?

TIA,
Patrick Price
Jul 18 '05 #1
1 3266
win32com.client .DispatchEx will create a new instance even if you already
have an instance of Excel running.
Roger

"Patrick" <jp@moment.ne t> wrote in message
news:81******** *************** ***@posting.goo gle.com...
I am investigating a web-based app wherein I wanted to provide html
form frontends to an Excel spreadsheet sitting on a MS Windows server;
with each authenticated HTTP user having thier own "invisible" copy of
the spreadsheet changeable via form POST via COM automation object
(via Python) - then after recalculating - present the spreadsheet
results in HTML. The whole idea to 1: isolate the user from having to
have Excel, and 2: avoiding rewriting the hundreds of Excel formulas
in a CGI.

HTML FORM -> POST -> Python win32com -> Spreadsheet -> Recalc -> HTML

Now the problem is that win32com.client .Dispatch apparently does not
play well with other Dispatch instances.

If I have two instances of Python running, and Dispatch two instances
of ("Excel.Applica tion"), I find that when I close one workbook, they
are all closed.

eg:
Python instance 1 in DOS window 1:

from win32com.client import Dispatch
x1 = Dispatch("Excel .Application")
x1.workbooks.op en("workbook1.x ls")
Python instance 2 in DOS window 2:

from win32com.client import Dispatch
x2 = Dispatch("Excel .Application")
x2.workbooks.op en("workbook2.x ls")
x2.workbooks.cl ose("workbook2. xls")

Guess what? Closing x2 also closes x1.

How do I get around this? I'm running this test from two DOS prompts.
Also any changes I make using x2 (like switching the sheet) appear in
the x1 instance.

Does DCOM resolve this; is this a failure with Excel; or is it how
win32com works; or is it just a COM problem?

TIA,
Patrick Price

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2635
by: It's me | last post by:
I've been using the win32com module with very good success in placing data onto an Excel spreadsheet. However, whenever I have an error in my script (like mapping a non-square array onto the spreadsheet), something breaks. After fixing my error and restart the Python program again, Excel would start up a window with a "Microsoft Excel - BookX" where X is a increasing number (1,2,3,4,....) instead of just 1. Then, the spreadsheet portion...
6
1989
by: Chris Curvey | last post by:
I'm having one of those weeks. I have this pattern all over my code. result = conn.execute("select * from foo") while not result.EOF: doSomething() result.MoveNext()
5
6162
by: Chris | last post by:
Hi, I'm trying to figure out how to submit javascript forms using win32com in order to complete repetitive processes. The Webpage Source: (I tried to include only the important stuff) ---------------------------------------------- <SCRIPT language="JavaScript"> function mainPageOnLoad() {
25
3746
by: Neil Ginsberg | last post by:
I have a strange situation with my Access 2000 database. I have code in the database which has worked fine for years, and now all of a sudden doesn't work fine on one or two of my client's machines. The code opens MS Word through Automation and then opens a particular Word doc. It's still working fine on most machines; but on one or two of them, the user is getting an Automation Error. The code used is as follows: Dim objWord As...
12
5536
by: Cheval | last post by:
Has anyone had any problems with inter-office automation between MS Word and MS Access in Office 2003? I have recently installed office 2003 in a new folder and have left the older office 2000 and office XP components installed. ie I have word/access/excel 2k/xp/2003 installed. I tried to do a usual access 2k to word 2k automation yet I get the error "Automation Error" "ClassFactory cannot supply requested class" when on late binding try...
17
6348
by: Mansi | last post by:
I need to do some research on how to use excel automation from c#. Does anyone know of any good books related to this subject? Thanks. Mansi
1
1726
by: Roland | last post by:
Hello, I'm trying to use Sparx Systems Enterprise Architect OLE automation interface. There is no problem to get early binding interface using Microsoft Visual Basic. But using win32com makepy utility there problem is. Does anybody have an idea, what may disqualify python win32com from creating early binding interface?
2
3300
by: ago | last post by:
I am trying to make the win32com HelloWorld server work with a VBA client but I get: Run-time error '-2147467259(80004005)': Automation error Unspecified error I googled for the error but the suggested solutions (commenting out _reg_class_spec_ and putting the server on the python path) do not seem to make any difference (to be precise, unless I comment out
3
6958
by: tyler.schlosser | last post by:
Hi there, I am trying to launch a program called AmiBroker using the command: AB = win32com.client.Dispatch("Broker.Application") However, I have a dual-core CPU and would like to launch two instances of AmiBroker. I know it is possible to run two instances simultaneously since it is easy to do manually by double-clicking the AmiBroker.exe file twice. However, when I write two lines of code like this:
0
9672
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
10213
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...
0
9040
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
7538
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
5436
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
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
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
2
3722
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.