Add custom toolbar and double click on a button = event handler fired three times

A

Angelos

Hi,

If you add a new toolbar with one button and then you double click on
the toolbar button, the Click event of the button is fired three times.
Is this a known bug? Is there some sort of workaround?

Here is the code to reproduce the behaviour

Private toolbar As CommandBar
Private WithEvents toolbarButton As CommandBarButton

Private Sub Document_New()
Set toolbar = CommandBars.Add("Test", 1, missing, True)

Set toolbarButton = toolbar.Controls.Add(1)
toolbarButton.Style = msoButtonCaption
toolbarButton.Caption = "Click me"
toolbarButton.Tag = "something unique"

toolbar.Visible = True
End Sub

Private Sub toolbarButton_Click(ByVal Ctrl As Office.CommandBarButton,
CancelDefault As Boolean)

Call Selection.Range.InsertAfter("Button clicked " &
DateTime.Time$)
Call Selection.Range.InsertParagraphAfter

End Sub

Thank you in advance
Angelos
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top