Hi,

Tim already answered the first problem you faced, let's see if I can
help with the others.

>> I do not understand why I cannot iterate in the collection of
Documents

While the collection you get back may (and I am not sure whether it does
or not) inherit from IEnumerable,
the code I put in IronPython doesn't detect it yet so we cannot iterate
it the tradiional Pythonic way. Anthony
Tarlano and I played with this already and we have been successful using
methods Count and Item on the 
collection (the collection we enumerated was collection of spelling
correction hints):

>>> import sys
>>> sys.LoadAssemblyByName('Microsoft.Office.Interop.Word')
>>> import Microsoft.Office.Interop.Word as Word
>>> wapp = Word.ApplicationClass()
>>> wapp.Documents.Add()
<com_object Microsoft.Office.Interop.Word.DocumentClass>
>>> s = wapp.GetSpellingSuggestions('tonny')

>>> for i in xrange(s.Count):
...     print s.Item(i + 1).Name

...
tinny
Tony
tiny
sonny
tone
>>> 

Same goes for collection of documents:

>>> import sys
>>> sys.LoadAssemblyByName("Microsoft.Office.Interop.Word")
>>> import Microsoft.Office.Interop.Word as wordApp
>>> mApp = wordApp.ApplicationClass()
>>> mApp.Visible=True
>>> mApp.Documents.Open("D:\\a.doc")
>>> mApp.Documents.Add()
>>> for i in xrange(mApp.Documents.Count):
...     print mApp.Documents.Item(i + 1).Name
...
Document1
a.doc
>>>
 
>>  I cannot select a given document using its Name 

I was able to access the document by name using slightly modified code:

>>> print mApp.Documents.Item("X.doc").Name
x.doc

>> I would like to translate the following vb statement in python
>> Documents.Open FileName:="C:\Files\Doc.doc", ReadOnly:=True

>>> doc3 = mApp.Documents.Open(FileName='c:\tmp\Doc1.doc', ReadOnly=
True)

Passing parameters by name to COM objects is not implemented in
IronPython.

To open document read only, you can do following:

 mApp.Documents.Open("D:\\x.doc", False, True)

The 3rd parameter is "Read Only". The rest of the parameters have
default values,
which IronPython will add.

The COM support in IronPython is going to be extended to get the best
possible experience. Currently the support is only very simple.

I hope this helps a little.

Martin
_______________________________________________
users-ironpython.com mailing list
users-ironpython.com@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to