From: Dominic Sisneros Date: 2008-06-04T09:04:11+09:00 Subject: win32ole , WIN32OLE_EVENT.new and Microstation Please Help! I am trying to control a Microstation application through its VBA api. I am able to connect to the object and control it but I am now trying to figure out how to deal with Microstation's event handling. In Microstation VBA you declare that a class implements an Event interface and make sure the class implements all the methods. You then call a method on the Application object app = WIN32OLE.new('MicrostationDGN.Application.1') app.visible = TRUE app.AddSaveAsEventsHandler SaveHandler I tried to create a class that implements the methods in 'ISaveAsEvents' class SaveHandler def AfterRedraw end def BeforeRedraw end end but get a segmentation fault because of type mismatch I also tried to use the WIN32OLE_EVENT class ev = WIN32OLE_EVENT.new(app, 'IViewUpdateEvents') => No such interface supported Here is a win32ole_pp of the 'AddSaveAsEventsHandler' method #]> ********* Here is an example that they show in the help file for Microstation. the following is the class file ' This is the implementation of clsEventHandlers. It has Implements statements declaring that it implements anevent interface. Implements IViewUpdateEvents ' ' Methods for the IViewUpdateEvents ' Private Sub IViewUpdateEvents_AfterRedraw(TheViews() As View, TheModels() As ModelReference, ByVal DrawMode As MsdDrawingMode) If UBound(TheModels) < 0 Then ' This is a normal update. Everything is being redrawn End If End Sub Private Sub IViewUpdateEvents_BeforeRedraw(TheViews() As View, TheModels() As ModelReference, ByVal DrawMode As MsdDrawingMode) End Sub ****************** Here is how the initialize it. Everything not declared defaults to the Application object Private oEventHandlers As clsEventHandlers Sub InstallHandlers() RemoveHandlers Set oEventHandlers = New clsEventHandlers AddViewUpdateEventsHandler oEventHandlers End Sub Sub RemoveHandlers() If Not oEventHandlers Is Nothing Then RemoveViewUpdateEventsHandler oEventHandlers End If Set oEventHandlers = Nothing End Sub