Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2008
    Posts
    11

    Unanswered: Create popup menu item with icon in VBA?

    Hi!

    I succesfuly made functions to dinamicaly create and manage popup menu.
    To be fully satisfied I would like to add to menu custom icons.

    I was unable to find in VBA help file information about icons for menus also the it was impossible to manage icons for created menu items throught customization interface of Access.

    So the questions is - is it possible to do that in VBA and Access 2003?

    Thanks in advance,
    Janeks

  2. #2
    Join Date
    Oct 2009
    Posts
    204
    Quote Originally Posted by janeks_k View Post
    Hi!

    I succesfuly made functions to dinamicaly create and manage popup menu.
    To be fully satisfied I would like to add to menu custom icons.

    I was unable to find in VBA help file information about icons for menus also the it was impossible to manage icons for created menu items throught customization interface of Access.

    So the questions is - is it possible to do that in VBA and Access 2003?

    Thanks in advance,
    Janeks
    I would just use a command button. You can put any picture you want on the button, and the button will look like an icon.

  3. #3
    Join Date
    Jul 2008
    Posts
    11
    How to put a command button on popup menu?

    Here I have my code:
    Code:
    Public Function GetPopUpMenu(menuName As String) As CommandBar
        Dim myBar As CommandBar
        If ExistPopUpMenu(menuName) Then
            Set GetPopUpMenu = CommandBars(menuName)
        Else
            Set GetPopUpMenu = CommandBars.Add(Name:=menuName, Position:=msoBarPopup, Temporary:=False)
        End If
    End Function
    
    Public Sub addItemToPopUp(aMenu As CommandBar, itemName As String, aFunc As String)
        Dim mItem As CommandBarControl
        Dim itemCount As Byte
        itemCount = aMenu.Controls.Count
        aMenu.Controls.Add
        aMenu.Controls(itemCount + 1).Caption = itemName
        aMenu.Controls(itemCount + 1).OnAction = aFunc
    End Sub

  4. #4
    Join Date
    Jul 2008
    Posts
    11

    The right key word in this case is "Face" not icon

    Finaly I found the solution.

    First I need to create static menu with my custom icons or use some from an existing builtin menus.

    Then in code we use:

    Code:
    getpopupmenu("existingStaticMenuName").Controls("ExisingControlName").CopyFace
    
    getpopupmenu("targetMenuName").Controls("targetControlName").PasteFace

Tags for this Thread

Posting Permissions

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