![]() |
Right mouse paste
I want to be able to open a menu when I right mouse click above a text box on
an Excel form to give me the usual 'Copy' & 'Paste' type of functionallity. I can detect the right mouse click using 'MouseUp' and trapping 'xlSecondaryButton' but don't know how to display the menu. Please help.... |
Right mouse paste
the commandbar for the right click menu on the worksheet is Cell and the
command to display it is Sub ABCD() CommandBars("Cell").ShowPopup End Sub However, in my opinion (and I haven't tested it so I could be surprised, but doubt it) You would need to create your own commandbar menu and put the code behind it that would copy the information out of the textbox. I would think the normal right click copy command is for copying information from whatever object produces the menu - it isn't a generic command that works on whatever has the focus. so to build you own: http://support.microsoft.com/default...02&Product=xlw How to customize menus and menu bars in Excel http://support.microsoft.com/default...b;en-us;166755 File Title: Customizing Menu Bars, Menus, and Menu Items in Microsoft(R) Excel 97 File Name: WE1183.EXE File Size: 58041 bytes File Date: 06/20/97 Keywords: kbfile kbappnote Description: This Application Note can help you learn techniques for writing Visual Basic(R) for Applications code to customize menus in Microsoft Excel 97. This Application Note contains code examples that you can use with the following elements: menu bars, menus, menu items, submenus, and shortcut menus. to put a text string in or pull text out of the Clipboard: http://www.cpearson.com/excel/clipboard.htm -- Regards, Tom Ogilvy "GDCobra" wrote: I want to be able to open a menu when I right mouse click above a text box on an Excel form to give me the usual 'Copy' & 'Paste' type of functionallity. I can detect the right mouse click using 'MouseUp' and trapping 'xlSecondaryButton' but don't know how to display the menu. Please help.... |
Right mouse paste
Hi Tom
Apologies for being so long getting back to you. Invoking the 'Cell' commandbar does bring up the RMB menu as you say but when I select 'Paste' the information gets pasted into the last active cell in the spreadsheet rather than the text box which called the function. The first link you suggested is proving useful, it seems I need to create a 'Shortcut Menu Bar' by defining the 'Position' parameter as 'msoBarPopup'. This is giving me a menu, which is currently empty, at a pre defined position on the screen. Sub Shortcut_Create() Dim myShtCtBar as Object Set myShtCtBar = CommandBars.Add(Name:="myShortcutBar", _ Position:=msoBarPopup) €˜ This displays the shortcut menu bar. €˜ 200, 200 refers to the screen position in pixels as x and y coordinates. myShtCtBar.ShowPopup 200,200 End Sub Jobs to do now a- 1) Populate the menu with items, Copy, Paste etc. 2) Detect the mouse position and use this on the 'myShtCtBar.ShowPopup 200,200' command. 3) Add code to the menu items to perform the required functions. Simple but all new ground for me so if anyone has any code for a similar function that may give some ideas it would be very welcome "Tom Ogilvy" wrote: the commandbar for the right click menu on the worksheet is Cell and the command to display it is Sub ABCD() CommandBars("Cell").ShowPopup End Sub However, in my opinion (and I haven't tested it so I could be surprised, but doubt it) You would need to create your own commandbar menu and put the code behind it that would copy the information out of the textbox. I would think the normal right click copy command is for copying information from whatever object produces the menu - it isn't a generic command that works on whatever has the focus. so to build you own: http://support.microsoft.com/default...02&Product=xlw How to customize menus and menu bars in Excel http://support.microsoft.com/default...b;en-us;166755 File Title: Customizing Menu Bars, Menus, and Menu Items in Microsoft(R) Excel 97 File Name: WE1183.EXE File Size: 58041 bytes File Date: 06/20/97 Keywords: kbfile kbappnote Description: This Application Note can help you learn techniques for writing Visual Basic(R) for Applications code to customize menus in Microsoft Excel 97. This Application Note contains code examples that you can use with the following elements: menu bars, menus, menu items, submenus, and shortcut menus. to put a text string in or pull text out of the Clipboard: http://www.cpearson.com/excel/clipboard.htm -- Regards, Tom Ogilvy "GDCobra" wrote: I want to be able to open a menu when I right mouse click above a text box on an Excel form to give me the usual 'Copy' & 'Paste' type of functionallity. I can detect the right mouse click using 'MouseUp' and trapping 'xlSecondaryButton' but don't know how to display the menu. Please help.... |
All times are GMT +1. The time now is 06:53 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com