[IronPython] Urgent : Unable to open MS Word file from Python
itssivaguru at gmail.com
Wed Jun 3 22:35:42 CEST 2009
I have written this small script, which is (part of an application that is)
supposed to open a MS Word Document and manipulate it (do a search and
I am getting a weird exception when I try to run the script.
It says TypeError: expected clr.Reference, got str for the line where I try
to open the file.
But the same script runs fine on a colleague's computer .
I couldn't figure out what his computer has that mine doesn't.So I thought
of asking what are the necessary things (libs, dlls) that are needed to
Open/Work on MS Word File from Iron Python.
MS Excel interaction works fine in my computer though. I have Office 07, MS
Visual Studio 05, .NET Framework 2.0 installed in my computer. I have also
verified that Microsoft.Office.Interop.Word version 188.8.131.52 is found
registered in the Assembly Cache.
This issue has become a Show-stopper for the Application I am working on.
So, any helpful suggestions or directions would mean a lot !
import Microsoft.Office.Interop.Word as Word
source_filename = 'C:\Sample_Report.doc'
destination_filename = 'c:\Validation Report.doc'
missing = System.Type.Missing
replaceAll = Word.WdReplace.wdReplaceAll
# Open the Report Template MSWord File
word_application = Word.ApplicationClass()
word_application.Visible = False
document = word_application.Documents.Open(source_filename)
print 'opened microsoft word'
document = None
word_application = None
Error Message :
> "C:\Program Files\DotQuestLite\Bin\ipy.exe" word.py
Traceback (most recent call last):
File C:\Documents and Settings\sp19206\Desktop\word.py, line 17, in
TypeError: expected clr.Reference, got str
> Process Exit Code: 1
> Time Taken: 00:07
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironpython-users