Help Dispatching Events on excel commandbar buttons

Eric ekoome at yahoo.com
Thu Aug 21 16:53:40 CEST 2003


I have the following function which creates buttons on Excel
commandbar. The problem i can't get the buttons to hook up to events.
For example, if i create four buttons only the fourth one fires the
ButtonEvent, the rest do nothing. What am i doing wrong.

Please help

Eric
--------------begin Function--------------------------
def CreateButton(self,menubar,buttons,images,captions, tooltips):
        """Create buttons on the Excel bar"""
        
        if menubar is not None:
            if buttons is not None:
                i=0
                for button in buttons:
                    button =
menubar.Controls.Add(Type=constants.msoControlButton,
Parameter="Greetings")
                    button=self.toolbarButton=
DispatchWithEvents(button, ButtonEvent)
                    button.BeginGroup = True
                    button.Width = "34"
                    if captions:
                        button.Caption =captions[i]
                    if tooltips:
                        button.TooltipText = tooltips[i]
                    i+=1  
----------------------end Function------------------------------




More information about the Python-list mailing list