CommandBar issue

G

Geoff

Hi
I picked up on a response from J.Rech, 10/24/2007 to "Custom Commandbar,
Submenu questions". The solution of using a Tag to find controls worked for
me too - for a while.

The two adapted lines below have succesfully run hundreds of times from an
addin on 2 stand alone pcs. But for some unknown reason they do not work any
more.
They do not error out and I would appreciate ideas on how to fix the problem.

CommandBars.FindControl(Tag:="MakeB").Enabled = False
CommandBars.FindControl(Tag:="HypeF").Enabled = True

The code below is run to install a custom menu when a workbook is opened and
has not failed at all. After executing button 1 the idea is then to disable
it and enable button 2. The 2 disable / enable statements are called at the
end of the button 1 OnAction module.

T.I.A.

Geoff


Sub InstallPopUpMenu()

Dim button1 As CommandBarButton, button2 As CommandBarButton

'''try to delete old menus that may have been left by a crash.
On Error Resume Next
Application.CommandBars.ActiveMenuBar.Controls("Custom Tools").Delete
On Error GoTo 0

'''create custom menu
Set popupbar =
CommandBars.ActiveMenuBar.Controls.Add(Type:=msoControlPopup, _

Before:=CommandBars.ActiveMenuBar _

..Controls.Count, Temporary:=True)

popupbar.Caption = "&Custom Tools"

'''create buttons on menu
Set button1 = popupbar.CommandBar.Controls.Add(Type:=msoControlButton,
ID:=1)
With button1
.Caption = "&XXX"
.Style = msoButtonIconAndCaption
.FaceId = 642
.OnAction = "xx"
.Tag = "MakeB"
End With

Set button2 = popupbar.CommandBar.Controls.Add(Type:=msoControlButton,
ID:=1)
With button2
.Caption = "&ZZZ"
.Style = msoButtonIconAndCaption
.FaceId = 6915
.OnAction = "zz"
.Enabled = False
.Tag = "HypeF"
.BeginGroup = True
End With

popupbar.Visible = True

End Sub
 

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