[IronPython] word Automation

kbond kbond at free.fr
Mon May 9 07:42:18 CEST 2005


Hello,

First congratulation of all, thank you for the tremendous work that you 
have already done.
I am looking forward the day where I will be able to translate all my MS 
office  automation in python  scripts.

Am I correct I say that iron python will allow it?

So today I try to give it a try but unfortunatly withou success till now.
I am trying to translate this simple vb.net module to iron python, is 
there someone reading this list that can help me?

the VB

Imports word = Microsoft.Office.Interop.word
Module Module1
 
 
    Sub Main()
        Dim oWord As Word.ApplicationClass
 
        'Start Word and open the document.
        oWord = CreateObject("Word.Application")
        oWord.Visible = True
        oWord.Documents.Open("C:\tmp\Doc1.doc")
 
        'Run the macros.
        'oWord.Run("DoKbTest")
        'oWord.Run("DoKbTestWithParameter", "Hello from VB .NET Client")
 
        'Quit Word.
        oWord.Quit()
        System.Runtime.InteropServices.Marshal.ReleaseComObject(oWord)
        oWord = Nothing
 
 
    End Sub
 
End Module


Iron Python

import sys
sys.LoadAssemblyByName("Microsoft.Office.Interop.Word")
import Microsoft.Office.Interop.Word as wordApp
oWord = wordApp.ApplicationClass
 
oWord = CreateObject("wordApp.Application")
oWord.Visible = True
oWord.Documents.Open("C:\tmp\Doc1.doc")
 
oWord.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(oWord)
oWord = Nothing

thank you




More information about the Ironpython-users mailing list