I
Ian
I want to have the window list available in the custom menu without having
some of the options on the builtin window menu such as hide/unhide available
on the custom menu.
I am trying to add a control button with builtin ID 830 to a custom menu in
VBA (MS Access 2003) and it fails giving the following error message:
Run-time error '-2147467259 (80004005)':
Method 'Add' of object 'CommandBarControls' failed
Sample code below:
Sub test2()
Dim cb As CommandBar
Dim cbButton As CommandBarButton
Dim cbCtl As CommandBarControl
Dim cbPopup As CommandBarPopup
'Add &Window control
Set cb = CommandBars("mnuDataSheet")
Set cbPopup = cb.Controls.Add(Type:=msoControlPopup, Id:=30009)
'Fails on next line
Set cbButton = cbPopup.Controls.Add(Type:=msoControlButton, Id:=830)
With cbButton
.Caption = "&Window Name Goes Here"
.Visible = False
End With
End Sub
some of the options on the builtin window menu such as hide/unhide available
on the custom menu.
I am trying to add a control button with builtin ID 830 to a custom menu in
VBA (MS Access 2003) and it fails giving the following error message:
Run-time error '-2147467259 (80004005)':
Method 'Add' of object 'CommandBarControls' failed
Sample code below:
Sub test2()
Dim cb As CommandBar
Dim cbButton As CommandBarButton
Dim cbCtl As CommandBarControl
Dim cbPopup As CommandBarPopup
'Add &Window control
Set cb = CommandBars("mnuDataSheet")
Set cbPopup = cb.Controls.Add(Type:=msoControlPopup, Id:=30009)
'Fails on next line
Set cbButton = cbPopup.Controls.Add(Type:=msoControlButton, Id:=830)
With cbButton
.Caption = "&Window Name Goes Here"
.Visible = False
End With
End Sub