[python-win32] Controling MS word from Pytonwin

Shamsul Azhar shamsul at handisplay.com.my
Wed Nov 12 23:57:23 EST 2003


Hi,

I'm currently writing an application to control MS-Word from Pythonwin. At
the moment I'm  having problems trying to activate a menu option in word.
The following code snippets should start Word and activate the "Open" menu
option.

Using VB the code would look something like :-

Private Sub Command1_Click()
    Dim wordApp As Word.Application
    Set wordApp = CreateObject("Word.Application")
    wordApp.Visible = True

    wordApp.CommandBars.FindControl(ID:=23).Execute
End Sub

Which when translates to Pythonwin would look like :-

wordApp = win32com.client.Dispatch("word.Application")
wordApp.visible = 1
wordApp.CommandBars.FindControl(Id=23).Execute

However it works fine in VB but in Pythonwin failed to execute the "Open"
menu option.

Hope somebody can help.

TIA.







More information about the Python-win32 mailing list