I am calling this module from the Workbook_Open event. I get the compile error "A module is not a valid type" on "Dim cBarParentBar As CommandBar". I have tried this before with success, although it was in a different workbook.
I would appreciate any suggestions. I have looked at this long enough...
Code:
Sub SetUpCommandBar()
Dim cBarParentBar As CommandBar
Dim cBarParentBarPopUp As CommandBarPopup
Dim cBarParentBarPopUpControls(1 To 5) As CommandBarButton
Dim intArrayCounter As Integer
Set cBarParentBar = Application.CommandBars("Worksheet Menu Bar")
On Error Resume Next
cBarParentBar.Controls("Excel to CSV").Delete
On Error GoTo 0
Set cBarParentBarPopUp = cBarParentBar.Controls.Add( _
msoControlPopup, , , , True)
With cBarParentBarPopUp
.Caption = "Excel to CSV"
.Visible = True
End With
For intArrayCounter = 1 To 5
Set cBarParentBarPopUpControls(intArrayCounter) = cBarParentBarPopUp.Controls.Add( _
msoControlButton, , , , True)
With cBarParentBarPopUpControls(intArrayCounter)
.Caption = "Add button # " & intArrayCounter
.Style = msoButtonCaption
.Visible = True
.OnAction = "CommandBarButton_Click"
.Tag = intArrayCounter
End With
Next
End Sub
I would appreciate any suggestions. I have looked at this long enough...