[python-win32] Re: FrontPage COM Object Events

Roger Upole rwupole at msn.com
Thu Aug 24 05:23:58 CEST 2006


># Hi
> # I want to get events of FrontPage Web and Page object models with this
> code.
> # OnPageNew and OnActivate works properly but when I click on the page
> nothing happen.
> # I know that I want to get events of two different COM objects.
> # But I don't know how can I do that.
> # (I run this when FrontPage is active. Then I create a new page.)
> # Thanks
> 
> from win32com.client import DispatchWithEvents
> import time, pythoncom, msvcrt, types
> 
> class FrontPageEvents:
>    def __init__(self):
>        print 'FrontPageEvents'
>    def OnPageNew(self, page):
>        global t1, t2
>        t1=DispatchWithEvents(page, PageExEvents)
>        t2=DispatchWithEvents(fp.ActiveDocument, PageEvents)
>        print fp.ActiveDocument
> 
> class PageExEvents:
>    def __init__(self):
>        print 'PageExEvents'
>    def OnActivate(self):
>        print 'OnActivate'
> 
> class PageEvents:
>    def __init__(self):
>        print 'PageEvents'
>    def onclick(self):
>        print 'onclick'
> 
> t1=None
> t2=None
> fp=DispatchWithEvents("FrontPage.Application", FrontPageEvents)
> 
> while not msvcrt.kbhit():
>    pythoncom.PumpWaitingMessages()
>    time.sleep(.2)
> msvcrt.getch()
>

Check the case of the onclick event.  The method
names are case-sensistive.

            Roger



More information about the Python-win32 mailing list