Page 1 of 3 123 LastLast
Results 1 to 15 of 37
  1. #1
    lawdy is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    172

    Unable to create shortcut menu

    I am having trouble creating a shortcut menu. I copied the following from the internet. It says to 'run' the code, so I put it in a module. When I run it, I get the error "User defined type not defined".

    Sub CreateSimpleShortcutMenu()
    Dim cmbShortcutMenu As Office.CommandBar



    ' Create a shortcut menu named "SimpleShortcutMenu.
    Set cmbShortcutMenu = CommandBars.Add("SimpleShortcutMenu", msoBarPopup, False, True)

    ' Add the Remove Filter/Sort command.
    cmbShortcutMenu.Controls.Add Type:=msoControlButton, ID:=605

    ' Add the Filter By Selection command.
    cmbShortcutMenu.Controls.Add Type:=msoControlButton, ID:=640

    Set cmbShortcutMenu = Nothing

    End Sub

    Anyone know what to do?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    Review this thread https://www.accessforums.net/modules...enu-44055.html
    See if referenced links help
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    lawdy is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    172
    I get the same results for 'Dim cmbShortcutMenu As Office.CommandBar' - "User defined type not defined".

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    If you want a right click shortcut menu, maybe this will be more helpful http://msdn.microsoft.com/en-us/library/ff194247.aspx

    I will have to give that a try this weekend.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    lawdy is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    172
    I got the same error - "User defined type not defined" regarding 'Dim cmbShortcutMenu As Office.CommandBar'

  6. #6
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    Dubai
    Posts
    614
    You have to set reference to Microsoft Office 14.0 Object Library ?

  7. #7
    lawdy is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    172
    I have it set to Microsoft Office 14.0 Object Library. In the article where I got the code (listed above) says to 'run' the code once and that I don't have to each time I start Access. I am not sure what that means, so I put it in a module, and then run the code. I have trived several codes from several articles. I always get the same error - "User defined type not defined"- regarding the 'dim' line 'Dim cmbShortcutMenu As Office.CommandBar'

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    I followed the instructions from last link I referenced.

    I ran the procedure and then the shortcut menu was available to the ShortcutMenuBar property of the form or report.

    However, I find that the code does have to be run again when the db is reopened.


    No idea why you get the error. If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    reference
    Microsoft Office XX.X Object Library

  10. #10
    lawdy is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    172
    Under references, Microsoft Office 14.0 Access database enjine object library is checks. Is 'cmbShortcutMenu As Office.CommandBar' a user defined type?

  11. #11
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    It is not. As stated, the code works for me.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    lawdy is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    172
    I just tried it again without any luck. Where does the code go?

  13. #13
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    I put it in a general module but it should work anywhere.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  14. #14
    lawdy is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    172
    That is what I did. I am doing something wrong!

  15. #15
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Page 1 of 3 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Print Preview Custom Shortcut Menu
    By Swatskeb in forum Modules
    Replies: 2
    Last Post: 05-22-2014, 08:02 PM
  2. create menu problem
    By jinz in forum Forms
    Replies: 1
    Last Post: 12-10-2012, 07:02 AM
  3. Unable to create new record in Forms
    By escapades_access in forum Forms
    Replies: 5
    Last Post: 03-16-2011, 03:23 PM
  4. Replies: 0
    Last Post: 01-27-2011, 09:58 AM
  5. custom shortcut menu help!
    By ninachopper in forum Access
    Replies: 5
    Last Post: 09-05-2010, 06:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums