Urgent : Unable to open MS Word file from Python
Hello,
I was trying to write a small script that opens an MS Word File and does something to it.
I am getting a weird exception when I try to run the script.
It says 'Type-Exception - Expected clr , provided - 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.
-----------------------------------------------------------------------------------------------------------------------------
Here is the script :
import clr
clr.AddReference("Microsoft.Office.Interop.Word")
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'
-------------------------------------------------------------------------------------------------------------------------------