Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Capture mouses X &Y position on a worksheet

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Capture mouses X &Y position on a worksheet

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   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Capture mouses X &Y position on a worksheet

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
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
unsure how to set up worksheet to capture data Gina[_2_] Excel Discussion (Misc queries) 0 August 4th 08 05:07 PM
Excel screen capture to capture cells and row and column headings jayray Excel Discussion (Misc queries) 5 November 2nd 07 11:01 PM
How do I capture info from multiple sheets to main worksheet? cempire5 Excel Discussion (Misc queries) 5 September 13th 07 03:36 AM
Macro to capture worksheet names El Bee Excel Worksheet Functions 2 July 13th 06 05:56 PM
How do I enable my mouses Horizontal Scroll in Excel 2007 Gupta A. Excel Discussion (Misc queries) 0 May 26th 06 06:41 PM


All times are GMT +1. The time now is 12:06 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"