Trouble opening MS Word file from Iron Python

Last post 06-03-2009 4:42 PM by Summer_Intern. 1 replies.

Sort Posts:

  • Trouble opening MS Word file from Iron Python

    05-29-2009, 3:09 PM

     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'

  • Re: Trouble opening MS Word file from Iron Python

    06-03-2009, 4:42 PM

     This error has become a show stopper in the application development. So any helpful suggestions would mean a lot !!!

Page 1 of 1 (2 items)