N
Nigel RS
Hi All
I have built a custom toolbar (code snippet below), the control button
OnAction calls a subroutine with a single parameter.
The subroutine simply displays a MsgBox informing the user of the status,
with a single OK button to cancel the Msgbox. However the user has to press
the OK control twice to cancel the MsgBox. I have established that
subroutine runs twice!
Can anyone explain why this happens and how to prevent it?
code snippet follows....
-------------------------------------------------------------------
Sub BuildTB()
Const tbName = "CFAM_TB"
Dim NewMenuBar As CommandBar
Dim NewMenu As CommandBarControl
Dim NewItem As CommandBarControl
Call RemoveMenus(tbName)
Set NewMenuBar = CommandBars.Add(MenuBar:=False)
With NewMenuBar
.Name = tbName
.Visible = True
With .Controls.Add(Type:=msoControlButton, _
temporary:=True)
.FaceId = 2817
.OnAction = "ExportData(1)"
.Caption = "Send All"
.Style = msoButtonIconAndCaption
End With
.Position = msoBarTop
.Protection = msoBarNoChangeVisible + _
msoBarNoResize + _
msoBarNoChangeDock + _
msoBarNoCustomize
End With
End Sub
I have built a custom toolbar (code snippet below), the control button
OnAction calls a subroutine with a single parameter.
The subroutine simply displays a MsgBox informing the user of the status,
with a single OK button to cancel the Msgbox. However the user has to press
the OK control twice to cancel the MsgBox. I have established that
subroutine runs twice!
Can anyone explain why this happens and how to prevent it?
code snippet follows....
-------------------------------------------------------------------
Sub BuildTB()
Const tbName = "CFAM_TB"
Dim NewMenuBar As CommandBar
Dim NewMenu As CommandBarControl
Dim NewItem As CommandBarControl
Call RemoveMenus(tbName)
Set NewMenuBar = CommandBars.Add(MenuBar:=False)
With NewMenuBar
.Name = tbName
.Visible = True
With .Controls.Add(Type:=msoControlButton, _
temporary:=True)
.FaceId = 2817
.OnAction = "ExportData(1)"
.Caption = "Send All"
.Style = msoButtonIconAndCaption
End With
.Position = msoBarTop
.Protection = msoBarNoChangeVisible + _
msoBarNoResize + _
msoBarNoChangeDock + _
msoBarNoCustomize
End With
End Sub