[IronPython] i thought this is odd: using Interop on Microsoft Word

Kelie kf9150 at gmail.com
Fri Nov 2 08:44:34 CET 2007

Hello group,

import clr
import Microsoft.Office.Interop.Word as Word

_progid_ = "Word.Application"

def get_active_object(progid):
    from System.Runtime.InteropServices import Marshal
        app = Marshal.GetActiveObject(progid)
        app = None
    return app
def get_active_application():
	return get_active_object(_progid_)

def get_documents():
    return get_active_application().Documents

if __name__ == '__main__':
    docs = get_documents()
#    print docs[1].FullName # This line causes AttributeError:
                            # 'tuple' object has no attribute 'FullName'
    print docs[1] # returns (Microsoft.Office.Interop.Word.DocumentClass, 1)
    print docs[2] # returns (Microsoft.Office.Interop.Word.DocumentClass, 2)
    print docs[1][0].FullName

This is the code that i tested. For the last couple of lines, i was
expecting that
docs[1] and docs[2] would return the document object instead of a
tuple with the first of its item being the document. Is this the
intended behavior?

Thank you,


More information about the Ironpython-users mailing list