473,385 Members | 1,564 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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.Application"), 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.open("workbook1.xls")
Python instance 2 in DOS window 2:

from win32com.client import Dispatch
x2 = Dispatch("Excel.Application")
x2.workbooks.open("workbook2.xls")
x2.workbooks.close("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 3208
win32com.client.DispatchEx will create a new instance even if you already
have an instance of Excel running.
Roger

"Patrick" <jp@moment.net> wrote in message
news:81**************************@posting.google.c om...
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.Application"), 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.open("workbook1.xls")
Python instance 2 in DOS window 2:

from win32com.client import Dispatch
x2 = Dispatch("Excel.Application")
x2.workbooks.open("workbook2.xls")
x2.workbooks.close("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
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...
6
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
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)...
25
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...
12
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...
17
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
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...
2
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...
3
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.