Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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....
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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....

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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....

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
cut,copy,paste using mouse mario Excel Discussion (Misc queries) 1 October 9th 06 01:43 PM
The right click on my mouse does not give me the option to paste Mouse Trouble Excel Discussion (Misc queries) 3 November 23rd 05 05:36 PM
User Form - frame scroll with wheel mouse and cut & paste from tex Kenjaro Excel Programming 3 February 8th 05 02:31 AM
moving mouse highlights cells without touching left mouse button bremboy Excel Discussion (Misc queries) 2 January 27th 05 06:19 PM
Paste text copied from Excel into External App.using right mouse click MikeR[_2_] Excel Programming 0 October 25th 04 01:37 PM


All times are GMT +1. The time now is 11:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"