[IronPython] Word and MissingMemberException, 'tuple' object has no attribute 'SaveAs

Frey576 freyp576 at yahoo.de
Sat Oct 7 23:48:03 CEST 2006


Hi,

I am new to IronPython but have a couple of years experience with Python.
Currently I am stuck with a problem trying to open a Word document (WordML)
and saving it as .rtf back to disk

The exception I get upon call of myDoc.SaveAs is:

MissingMemberException, 'tuple' object has no attribute 'SaveAs'

when I check myDoc (obtained from Word.Documents.Open) in the CLR debugger I
see indeed that I got a tuple
but it does not look like a Python tuple and I dont know how to handle that:

-       myDoc   {(<DocumentClass object at 0x000000000000002B>,
'D:\\Projekte\\SGMLtoRtf\\dirWatch_SGMLtoRtf\\test\\HelloWorld.xml',
<Missing object at 0x000000000000002C>, True, <Missing object at
0x000000000000002C>, <Missing object at 0x000000000000002C>, <Missing object
at 0x000000000000002C>, <Missing object at 0x000000000000002C>, <Missing
object at 0x000000000000002C>, <Missing object at 0x000000000000002C>,
<Missing object at 0x000000000000002C>, <Missing object at
0x000000000000002C>, <Missing object at 0x000000000000002C>, <Missing object
at 0x000000000000002C>, <Missing object at 0x000000000000002C>, <Missing
object at 0x000000000000002C>, <Missing object at 0x000000000000002C>)}
object {IronPython.Runtime.Tuple}

so the type is IronPython.Runtime.Tuple
What is wrong with using Documents.Open from IronPython?

My script, stripped down a little bit, is:

import System.Type

import clr
clr.AddReferenceByPartialName("Microsoft.Office.Interop.Word")
import Microsoft.Office.Interop.Word as Word # ApplicationClass,
WdSaveFormat 

import sys
sys.path.append(r"c:\python24\lib")
import os

inPath = r".\test\HelloWorld.xml"
inPath = os.path.abspath(inPath)
assert os.path.isfile(inPath), "not found: %s" % inPath
    
outPath = os.path.splitext(inPath)[0] +".rtf"
    
app = Word.ApplicationClass()
try:
    readOnly = True
    myDoc = app.Documents.Open(inPath, System.Type.Missing, readOnly,
*[System.Type.Missing]*13);

    myDoc.SaveAs( outPath,
        Word.WdSaveFormat.wdFormatRTF, # FileFormat
        System.Type.Missing, # LockComments
        System.Type.Missing, # Password
        False,    # AddToRecentFiles
        System.Type.Missing, # WritePassword
        System.Type.Missing, # ReadOnlyRecommended
        System.Type.Missing, # EmbedTrueTypeFonts
        System.Type.Missing, # SaveNativePictureFormat
        System.Type.Missing, # SaveFormsData
        System.Type.Missing, # SaveAsAOCELetter
        System.Type.Missing, # Encoding
        System.Type.Missing, # InsertLineBreaks
        System.Type.Missing, # AllowSubstitutions
        System.Type.Missing, # LineEnding
        System.Type.Missing, # AddBiDiMarks
    )
    myDoc.Close(
        False, # SaveChanges
        System.Type.Missing, # OriginalFormat
        System.Type.Missing, # RouteDocument
    )
    
finally:
    app.Quit(*[System.Type.Missing]*3)    


How can I call member functions of a Word document obtained from
Documents.Open?

Peter






-- 
View this message in context: http://www.nabble.com/Word-and-MissingMemberException%2C-%27tuple%27-object-has-no-attribute-%27SaveAs-tf2402444.html#a6698479
Sent from the IronPython mailing list archive at Nabble.com.




More information about the Ironpython-users mailing list