Need Help: Trouble adding a custom menu pick to a custom popup menu in VBA 
Author Message
 Need Help: Trouble adding a custom menu pick to a custom popup menu in VBA

I'm trying to add a custom popup menu to MS Word (seems to be working), but
I can't seem to add a custom menu button to that new custom popup menu.
I've tried the following code in VBA.  What am I doing wrong?

Sub NewMenuPickCode()
    Dim cbarpop As CommandBarPopup
    Dim cbpick As CommandBarButton
    Dim oThisApp As Word.Application

    Set oThisApp = Application.Application

    Set cbarpop = oThisApp.CommandBars("Menu
Bar").Controls.Add(msoControlPopup, , , , True)
    cbarpop.Caption = "CustomTopMenuBar"
    cbarpop.OLEMenuGroup = msoOLEMenuGroupContainer
    cbarpop.OLEUsage = msoControlOLEUsageBoth
    cbarpop.Visible = True

    ' This fails, but if I put "Tools" in place of "CustomTopMenuBar", it
works fine.
    Set cbpick =
oThisApp.CommandBars("CustomTopMenuBar").Controls.Add(msoControlButton, ,
True)
    cbpick.Caption = "CustomSubMenu1"
    cbpick.Style = msoButtonCaption
    cbpick.Visible = True
End Sub

Thanks in advance for any help!

-Michael



Mon, 17 Mar 2003 03:00:00 GMT  
 Need Help: Trouble adding a custom menu pick to a custom popup menu in VBA
Michael,
Comments  interspersed in code.

' ---- Beginning Of Code -----
Sub NewMenuPickCode()
    Dim cbarpop As CommandBarPopup
    Dim cbpick As CommandBarButton
    Dim oThisApp As Word.Application

    Set oThisApp = Application

    Set cbarpop = oThisApp.CommandBars("Menu Bar"). _
            Controls.Add(msoControlPopup, , , , True)
    cbarpop.Caption = "CustomTopMenuBar"
    cbarpop.OLEMenuGroup = msoOLEMenuGroupContainer
    cbarpop.OLEUsage = msoControlOLEUsageBoth
    cbarpop.Visible = True

' You can't reference CustomTopMenuBar as a commandbar since
' it is defined as a commandbarpopup type.
' You already have a reference to the new commandbar popup, so
' just add the controls to CustomTopMenuBar as follows.

    Set cbpick = cbarpop.Controls.Add(msoControlButton, , True)
    cbpick.Caption = "CustomSubMenu1"
    cbpick.Style = msoButtonCaption
    cbpick.Visible = True
End Sub
' ---- End Of Code -----
--
Regards
Shyam Pillai

http://officetips.homepage.com

Please reply in newsgroup - No email replies .

...


Quote:
> I'm trying to add a custom popup menu to MS Word (seems to be working),
but
> I can't seem to add a custom menu button to that new custom popup menu.
> I've tried the following code in VBA.  What am I doing wrong?

> Sub NewMenuPickCode()
>     Dim cbarpop As CommandBarPopup
>     Dim cbpick As CommandBarButton
>     Dim oThisApp As Word.Application

>     Set oThisApp = Application.Application

>     Set cbarpop = oThisApp.CommandBars("Menu
> Bar").Controls.Add(msoControlPopup, , , , True)
>     cbarpop.Caption = "CustomTopMenuBar"
>     cbarpop.OLEMenuGroup = msoOLEMenuGroupContainer
>     cbarpop.OLEUsage = msoControlOLEUsageBoth
>     cbarpop.Visible = True

>     ' This fails, but if I put "Tools" in place of "CustomTopMenuBar", it
> works fine.
>     Set cbpick =
> oThisApp.CommandBars("CustomTopMenuBar").Controls.Add(msoControlButton, ,
> True)
>     cbpick.Caption = "CustomSubMenu1"
>     cbpick.Style = msoButtonCaption
>     cbpick.Visible = True
> End Sub

> Thanks in advance for any help!

> -Michael




Thu, 20 Mar 2003 11:39:11 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. When adding second menu item to custom menu it appears greyed out

2. Adding custom menu items to explorer menu

3. Adding custom menu items to explorer menu

4. Invoking custom help file from a custom menu

5. custom menu picking up wrong macros

6. help with creating a vba custom menu item?

7. Disable custom menu popup item

8. Popup a custom Word menu from container

9. ??Custom Popup Menu??

10. Popup Menus in VB5 Custom Controls

11. Popup Menus in VB5 custom controls

12. Need Lots of help; custom menu action

 

 
Powered by phpBB® Forum Software