Hello group,

import clr
clr.AddReference("Microsoft.Office.Interop.Word")
import Microsoft.Office.Interop.Word as Word

_progid_ = "Word.Application"

def get_active_object(progid):
    from System.Runtime.InteropServices import Marshal
    try:
        app = Marshal.GetActiveObject(progid)
    except:
        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,

-- 
Kelie
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to