instantiate multiple automation objects

Yoon S. Choi ychoi at pipeline.com
Sun Jun 4 23:00:44 EDT 2000


Thanks Roger.  That did the trick.  You saved me hours of time and
hair-pulling.



On Sun, 04 Jun 2000 15:18:26 GMT, "Roger Upole" <rupole at compaq.net>
wrote:

>win32com.client.Dispatch always tries to connect to a running
>instance first, so if you've already done a Dispatch for that
>object, any subsequent call will return the same instance.
>However, you could use DispatchEx to get a second
>instance, as it apparently doesn't try to connect to a running
>instance first.
>           HTH
>                  Roger Upole
>
>
>"Yoon S. Choi" <ychoi at pipeline.com> wrote in message
>news:3939d663.1392772 at nntp.pipeline.com...
>> I am trying (without much luck) to create multiple instances of an
>> automation object.  I can create 1 instance correctly using the
>> function call win32com.client.Dispatch().  However, when I use the
>> same function to try and create another automation object, it just
>> refers to the first instance.
>>
>> Here is an example using Microsoft Word as the automation object:
>>
>> import win32com.client
>> w1 = win32com.client.Dispatch( "Word.Application")
>> w2 = win32com.client.Dispatch( "Word.Application")
>> w1.Visible = 1  # Microsoft Word becomes visible
>> w2.Visible = 1  # Nothing happens because w2 is referring to the same
>> object as w1
>>
>> How can I for example create another instance of Microsoft Word?  In
>> other words, w1 and w2 would refer to two separate automation objects
>> of the same type.
>> Can I do this without having to resort directly to the pythoncom
>> module and its associated CoCreateInstance and CoGetClassObject
>> functions?
>
>




More information about the Python-list mailing list