Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Capture mouses X&Y position on a worksheet. I want to use
the before right click option of the worksheet to display a custom toolbar. I want to use the current position of the mouse to set the left and top parameters for the toolbar. Is there a better way? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Stewart,
Are you trying to show a popup menu that you've created? If so, you don't need to know the coordinates; you can use the ShowPopup method without any arguments to show the menu. Here's some (very ugly) code that gives you a quick overview of how you could accomplish this. Typically, you'd want to create your menu upon workbook open, pop it up as needed, and destroy it at workbook close. Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _ Cancel As Boolean) On Error Resume Next Application.CommandBars("jake").Delete On Error GoTo 0 With Application.CommandBars.Add("jake", msoBarPopup, , True) With .Controls.Add(msoControlPopup) .Caption = "&Edit" With .Controls.Add(msoControlButton) .Caption = "&Copy" End With With .Controls.Add(msoControlButton) .Caption = "&Paste" End With End With .ShowPopup End With Cancel = True End Sub -- Regards, Jake Marx MS MVP - Excel www.longhead.com [please keep replies in the newsgroup - email address unmonitored] Stewart wrote: Capture mouses X&Y position on a worksheet. I want to use the before right click option of the worksheet to display a custom toolbar. I want to use the current position of the mouse to set the left and top parameters for the toolbar. Is there a better way? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Got it - thanks!
-----Original Message----- Hi Stewart, Are you trying to show a popup menu that you've created? If so, you don't need to know the coordinates; you can use the ShowPopup method without any arguments to show the menu. Here's some (very ugly) code that gives you a quick overview of how you could accomplish this. Typically, you'd want to create your menu upon workbook open, pop it up as needed, and destroy it at workbook close. Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _ Cancel As Boolean) On Error Resume Next Application.CommandBars("jake").Delete On Error GoTo 0 With Application.CommandBars.Add("jake", msoBarPopup, , True) With .Controls.Add(msoControlPopup) .Caption = "&Edit" With .Controls.Add(msoControlButton) .Caption = "&Copy" End With With .Controls.Add(msoControlButton) .Caption = "&Paste" End With End With .ShowPopup End With Cancel = True End Sub -- Regards, Jake Marx MS MVP - Excel www.longhead.com [please keep replies in the newsgroup - email address unmonitored] Stewart wrote: Capture mouses X&Y position on a worksheet. I want to use the before right click option of the worksheet to display a custom toolbar. I want to use the current position of the mouse to set the left and top parameters for the toolbar. Is there a better way? . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
unsure how to set up worksheet to capture data | Excel Discussion (Misc queries) | |||
Excel screen capture to capture cells and row and column headings | Excel Discussion (Misc queries) | |||
How do I capture info from multiple sheets to main worksheet? | Excel Discussion (Misc queries) | |||
Macro to capture worksheet names | Excel Worksheet Functions | |||
How do I enable my mouses Horizontal Scroll in Excel 2007 | Excel Discussion (Misc queries) |