Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Levin, Manawatu-Wanganui, New Zealand
    Posts
    324
    Thanks
    9
    Thanked 28 Times in 26 Posts

    Defining a custom Menu with VBA

    Access 97 SR-1
    Greetings

    Some advice would be appreciated to point me on the way.
    I am attempting to code a custom menu, my first such attempt.
    The top Level on menu bar is to be CUSTOM
    I want the next item to be SEARCH

    The code bombs with Error 438, Object doesnt support this property or method
    ----------------------------------------------------
    Sub CustomMenu()
    Dim cbr As CommandBar
    Dim cbcCustom As CommandBarControl
    Dim cbcSearch As CommandBarControl

    Set cbr = CommandBars("menu Bar")
    Set cbcCustom = cbr.Controls.Add(msoControlButton)
    With cbcCustom
    .Caption = "Custom"
    .Tag = "Test Menu Item"
    .Style = msoButtonCaption
    End With
    Set cbcSearch = cbcCustom.CommandBar.Add(msoControlButton)
    With cbcSearch
    .Caption = "Search"
    .Tag = "search"
    .Style = msoButtonCaption
    End With
    End Sub
    -------------------------------------------

    CUSTOM sits very nicely on the Menu Bar even though it has bombed defining SEARCH.

    Thanks in anticipation
    G

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Defining a custom Menu with VBA

    Hi Geof,

    The reason for the error is that you're creating a Control Button ("Custom"). You should use the msoControlPopup style for "Custom". (You'll have to remove the line that sets the style of Custom to msoButtonCaption - because it's a popup it doesn't need that line.)

    Hopefully this will get you started in the right direction.
    HTH <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>

  3. #3
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Levin, Manawatu-Wanganui, New Zealand
    Posts
    324
    Thanks
    9
    Thanked 28 Times in 26 Posts

    Re: Defining a custom Menu with VBA

    Thanks Mark
    That did the trick. Oh so simple...
    <img src=/S/nuts.gif border=0 alt=nuts width=15 height=15>

    Geof

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •