I have some troubles with events from word97. My application now works great with Word2000 - but this is another python interface file (from makepy). But when i try unistall w2k and install w97 i must write another events handler. And now i have only OnDocumentChange event. Why i don't get any OnQuit message? Also when i ran
testMSOfficeEvents.py test :| <br>But in 00020905-0000-0000-C000-000000000046x1033x8x0.py i see:<br># Event Handlers<br># If you create handlers, they should have the following prototypes:<br># def OnQuit(self):<br># def OnStartup(self):
<br># def OnDocumentChange(self):<br><br>And another question - how to detect via win32com Word version - its my self.wordVer variable. <br>Mayby i must write my own Document class? Please some help with this problem!<br>
[w.p.]<br><br>I use this code (incompleted):<br><br>########################<br>class KwWordEvents: # word2000<br>########################<br> def OnQuit(self):<br> print "OnQuit"<br> self.seen_events["OnQuit"] = None
<br><br> def OnDocumentBeforeSave(self, Doc, SaveAsUI, Cancel):<br> print "OnDocumentBeforeSave"<br> self.seen_events["OnDocumentBeforeSave"] = None<br><br> def OnDocumentBeforeClose(self, Doc, Cancel):
<br> print "OnDocumentBeforeClose"<br> self.seen_events["OnDocumentBeforeClose"] = None<br> <br><br>########################<br>class KwWordEvents8: # word 97<br>########################<br>
def OnQuit(self):<br> print "w97 OnQuit"<br> self.seen_events["OnQuit"] = None<br><br> def OnStartup(self):<br> print "w97 OnStartup"<br> self.seen_events["OnStartup"] = None
<br><br> def OnDocumentChange(self):<br> print "w97 OnDocumentChange"<br> self.seen_events["OnDocumentChange"] = None<br><br>########################<br>class KwWord:<br>########################
<br> def __init__(self):<br> self.wordVer = self.GetWordVer()<br> if self.wordVer<=8:<br> self.wordApp = win32com.client.DispatchWithEvents("Word.Application", KwWordEvents8)<br> else:<br>
self.wordApp = win32com.client.DispatchWithEvents("Word.Application", KwWordEvents)<br><br> def GetWordVer(self):<br> ???<br>