views:

32

answers:

1

In Cpython, I can use win32com.

But, in ironpython, I didn't know how to import it.

Because, in .net, one always use Visual Studio to interop the COM and to use it.

+2  A: 

You should be able to create an IDispatch object using:

from System import Type, Activator
Activator.CreateInstance(Type.GetTypeFromProgID(com_type_name))

This is equivalent to win32com.client.Dispatch(com_type_name).

If there's a type lib you should be able to do:

import clr
import System
typelib = clr.LoadTypeLibrary(System.Guid("00020905-0000-0000-C000-000000000046"))
word = typelib.Word.Application()

I don't know what that's equivalent to. I'm not much of an expert on this but I took those from IronPython's cominterop_util which is used in the tests. There's more stuff in the IronPython\Tests\interop\com directory which might be useful.

Dino Viehland