Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Capturing pointer locations

Has anyone had any success capturing pointer locations
within Excel? According to "MouseDown, MouseUp Events"
within Help, when you click on "Applies To", both events
should apply to a UserForm, so the following should allow
you to capture the pointer location of a UserForm:

Private Sub UserForm_MouseDown(Button, Shift, X, Y)
MsgBox X
MsgBox Y
End Sub

However, this does not work, and when you read Help
for "MouseDown" alone, it supposedly only applies to a
chart object.

I would like to capture the mouse location on a
spreadsheet and also a UserForm, so has anyone been able
to do this?

Regards
Paul
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 176
Default Capturing pointer locations

Paul,

Mousedown certainly works for me.

Where are you putting your code? Since it is a userform event, the code for it must go into the userform's codemodule and not a
standard module. All but the Msgbox lines should autogenerate when you select the userform's codemodule's MouseDown event.

Private Sub UserForm_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, _
ByVal X As Single, _
ByVal Y As Single)
MsgBox "X of the click: " & X
MsgBox "Y of the click: " & Y
End Sub

HTH,
Bernie
Excel MVP


"Paul" wrote in message ...
Has anyone had any success capturing pointer locations
within Excel? According to "MouseDown, MouseUp Events"
within Help, when you click on "Applies To", both events
should apply to a UserForm, so the following should allow
you to capture the pointer location of a UserForm:

Private Sub UserForm_MouseDown(Button, Shift, X, Y)
MsgBox X
MsgBox Y
End Sub

However, this does not work, and when you read Help
for "MouseDown" alone, it supposedly only applies to a
chart object.

I would like to capture the mouse location on a
spreadsheet and also a UserForm, so has anyone been able
to do this?

Regards
Paul



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Capturing pointer locations

I don't believe Bernie showed:

Private Sub UserForm_MouseDown(Button, Shift, X, Y)

Your button shift x and y are variants which doesn't match what is expected.

He showed:

Private Sub UserForm_MouseDown(ByVal Button As Integer, _
ByVal Shift As
Integer, _
ByVal X As
Single, _
ByVal Y As
Single)
MsgBox "X of the click: " & X
MsgBox "Y of the click: " & Y
End Sub

So use it as he posted it. You are not defining the event - it is already
defined. That is why it is always best to select the event from the
dropdowns and let excel put in the declaration.

Your code worked fine for me when I substituted Bernie's event code.

Regards,
Tom Ogilvy


Paul Shepherd wrote in message
...

Hi Bernie, thanks for your reply.

I've put the code in the userform's code module, which I access by
double clicking the userform while in design mode. The userform is
initialized from the following code in a standard module:

Global userfm1 As UserForm1
Sub define_frame() 'Cntl-a calls UserForm1
Set userfm1 = New UserForm1
userfm1.Show
End Sub

where subroutine define_frame() is executes by typing control-a from a
worksheet.

However, with the following in the useform's code module:

Private Sub UserForm_MouseDown(Button, Shift, X, Y)
MsgBox X
MsgBox Y
End Sub

I receive a compiler error "Procedure does not match description of
event or procedure having the same name". Also, the only autogeneration
of coding that occurs is the appearance of the "End Sub". I guess I'm
doing something wrong! Please advise me if you know what it could be.

Thanks again.
Paul

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



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
Capturing Top 5 Performers Questor Excel Worksheet Functions 5 April 18th 09 11:33 PM
capturing all of the data jimbo Excel Worksheet Functions 7 July 27th 08 06:10 PM
Capturing excel screenshots vsoler Excel Discussion (Misc queries) 8 June 17th 07 06:06 AM
Capturing Date Larry Fish via OfficeKB.com New Users to Excel 4 September 27th 06 01:40 PM
Capturing data using a formula JR Excel Discussion (Misc queries) 9 February 15th 06 11:59 PM


All times are GMT +1. The time now is 02:17 AM.

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

About Us

"It's about Microsoft Excel"