Timothy Riley
Timothy Riley

Reputation: 49

How can I create multiple application instances in pythoncom?

I am attempting to use python to start up multiple processes using COM to asynchronously process several files (using concurrent.futures), but I can only manage to start up one process at a time.

Here's an easy way to see the problem using Excel:

import win32com.client

# start first instance
exl1 = win32com.client.Dispatch("Excel.Application")

# start second instance
exl2 = win32com.client.Dispatch("Excel.Application")

The second Excel process doesn't start up (I only see the process id of the first instance). Is there any way to accomplish this?

Upvotes: 1

Views: 1530

Answers (1)

Timothy Riley
Timothy Riley

Reputation: 49

Found the answer (from here: https://stackoverflow.com/a/517975/4755456). Use the DispatchEx method instead:

import win32com.client

# start first instance
exl1 = win32com.client.DispatchEx("Excel.Application")

# start second instance
exl2 = win32com.client.DispatchEx("Excel.Application")

Upvotes: 2

Related Questions