Devin
Board Regular
- Joined
- Jan 21, 2009
- Messages
- 105
I started using some code, but it seems to not be deleting all the controls upon exit. Since I have been using this for a little while, many copies of this control are popping up when I hit the application key while an entire column is selected. How do I need to adjust my DELETE code?
Thanks guys!!!!
Thanks guys!!!!
Code:
Sub AddToCellMenu()
Dim cbr As CommandBar
For Each cbr In Application.CommandBars
Debug.Print cbr.Name
If LCase$(cbr.Name) = "cell" Then
With cbr.Controls.Add(msoControlButton, Before:=4)
.Caption = "UnHide All"
.Tag = "UnHide All"
.OnAction = "UnHideAll"
.FaceId = 10
.Enabled = True
.Visible = True
End With
With Application.CommandBars(cbr.Index + 4).Controls.Add(msoControlButton, Before:=4)
.Caption = "UnHide All"
.Tag = "UnHide All"
.OnAction = "UnHideAll"
.FaceId = 10
.Enabled = True
.Visible = True
End With
End If
Next cbr
End Sub
Sub DeleteFromCellMenu()
Dim ContextMenu As CommandBar
Dim ctrl As CommandBarControl
Set ContextMenu = Application.CommandBars("Cell")
For Each ctrl In ContextMenu.Controls
If ctrl.Tag = "UnHide All" Then
ctrl.Delete
End If
Next ctrl
End Sub