mousedown event on a worksheet? 
Author Message
 mousedown event on a worksheet?

Is there a way to get X and Y values for a mousedown (or click) event
on a worksheet (similar to the chart_mousedown event)?

The application I'm writing involves a number of jpeg pictures tiled
together to form a large image (actually a series of astronomical
photographs).  I want the user to be able to click on an object in the
photos and have the routine return a message box with information
about the coordinates and name etc. of the object.  So far the only
way I can do this is to have the user draw a small rectangle over the
object, select the rectangle and then have the user manually run a
subroutine that uses the .top, .left, .height, .width properties of
the rectangle to get the x and y coordinates needed for extracting the
data to display to the user)



Mon, 18 Jul 2005 18:59:37 GMT  
 mousedown event on a worksheet?
Hi,

Assign a macro to each picture (rightclick the pic and
choose assign macro) with e.g. this code:

Sub Picture1_Click()
MsgBox ActiveSheet.Shapes
(Application.Caller).TopLeftCell.Address
End Sub

Now work out a way to find out what is where...

Regards,

Jan Karel Pieterse
Excel TA/MVP

Quote:
>-----Original Message-----
>Is there a way to get X and Y values for a mousedown (or
click) event
>on a worksheet (similar to the chart_mousedown event)?

>The application I'm writing involves a number of jpeg
pictures tiled
>together to form a large image (actually a series of
astronomical
>photographs).  I want the user to be able to click on an
object in the
>photos and have the routine return a message box with
information
>about the coordinates and name etc. of the object.  So
far the only
>way I can do this is to have the user draw a small
rectangle over the
>object, select the rectangle and then have the user
manually run a
>subroutine that uses the .top, .left, .height, .width
properties of
>the rectangle to get the x and y coordinates needed for
extracting the
>data to display to the user)
>.



Mon, 18 Jul 2005 21:09:50 GMT  
 mousedown event on a worksheet?
rhmd,

How about placing a label, from the control toolbox, over all the
pictures. Format it to be transparent with no border. You can then place
some vba code in the mousedown / mouseup / mousemove events.

Private Sub Label1_MouseDown(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)

     Label1.Parent.Select  ' stops the label from obscuring the pic
     MsgBox "Click " & X & " " & Y

End Sub

Quote:

> Is there a way to get X and Y values for a mousedown (or click) event
> on a worksheet (similar to the chart_mousedown event)?

> The application I'm writing involves a number of jpeg pictures tiled
> together to form a large image (actually a series of astronomical
> photographs).  I want the user to be able to click on an object in the
> photos and have the routine return a message box with information
> about the coordinates and name etc. of the object.  So far the only
> way I can do this is to have the user draw a small rectangle over the
> object, select the rectangle and then have the user manually run a
> subroutine that uses the .top, .left, .height, .width properties of
> the rectangle to get the x and y coordinates needed for extracting the
> data to display to the user)

--

Cheers
Andy

http://www.andypope.info



Mon, 18 Jul 2005 21:58:26 GMT  
 mousedown event on a worksheet?
I may be missing something, but...

For each image, right click on it and select Assign Macro... to assign
a macro to run when the user clicks on the image.

--
Regards,

Tushar Mehta (www.tushar-mehta.com) MS MVP -- Excel


Quote:
> Is there a way to get X and Y values for a mousedown (or click) event
> on a worksheet (similar to the chart_mousedown event)?

> The application I'm writing involves a number of jpeg pictures tiled
> together to form a large image (actually a series of astronomical
> photographs).  I want the user to be able to click on an object in the
> photos and have the routine return a message box with information
> about the coordinates and name etc. of the object.  So far the only
> way I can do this is to have the user draw a small rectangle over the
> object, select the rectangle and then have the user manually run a
> subroutine that uses the .top, .left, .height, .width properties of
> the rectangle to get the x and y coordinates needed for extracting the
> data to display to the user)



Tue, 19 Jul 2005 05:56:50 GMT  
 mousedown event on a worksheet?
You're not missing anything; you detected an error in my choice of
words.  By "information...about the object" I meant information about
the astronomical objects (galaxies, quasars, etc.) depicted on the VBA
object (picture).  For purposes of clarity, I should have referred to
the galaxies, quasars, etc. as astronomical "entities," not "objects."
 There can be hundreds of astronomical entities on a single picture.
The VBA routine I'm writing keeps track of where each picture is on
worksheet: say the user clicked on a galaxy whose mousedown X and Y
were (305, 510) and this X,Y was on a picture whose top-left was
(200,400), then the VBA routine would know that the user wanted info
on the astronomical entity located at (105, 110)  from the top-left of
the picture.  The VBA routine (knowing, say, that the scale of the
picture was 200 VBA X,Y units per degree of sky and knowing the
location of the picture in the sky) would compute the astronomical
coordinates of the sky area the user clicked on and then look in
various worksheets to find astronomical entities near that point and
return a message box saying, for example, "You just clicked on 3C273,
a quasar with redshift .156, magnitude 12.86, also classified as a
Seyfert type 1, blazar, etc etc."
Quote:

> I may be missing something, but...

> For each image, right click on it and select Assign Macro... to assign
> a macro to run when the user clicks on the image.

> --
> Regards,

> Tushar Mehta (www.tushar-mehta.com) MS MVP -- Excel



> > Is there a way to get X and Y values for a mousedown (or click) event
> > on a worksheet (similar to the chart_mousedown event)?

> > The application I'm writing involves a number of jpeg pictures tiled
> > together to form a large image (actually a series of astronomical
> > photographs).  I want the user to be able to click on an object in the
> > photos and have the routine return a message box with information
> > about the coordinates and name etc. of the object.  So far the only
> > way I can do this is to have the user draw a small rectangle over the
> > object, select the rectangle and then have the user manually run a
> > subroutine that uses the .top, .left, .height, .width properties of
> > the rectangle to get the x and y coordinates needed for extracting the
> > data to display to the user)



Tue, 19 Jul 2005 19:10:12 GMT  
 mousedown event on a worksheet?
How does one make a control toolbox label (or any other control for
that matter) transparent with no border?  It must be something trivial,
but for the life of me, I cannot figure it out.

--
Regards,

Tushar Mehta (www.tushar-mehta.com) MS MVP -- Excel


says...

Quote:
> rhmd,

> How about placing a label, from the control toolbox, over all the
> pictures. Format it to be transparent with no border. You can then place
> some vba code in the mousedown / mouseup / mousemove events.

> Private Sub Label1_MouseDown(ByVal Button As Integer, ByVal Shift As
> Integer, ByVal X As Single, ByVal Y As Single)

>      Label1.Parent.Select  ' stops the label from obscuring the pic
>      MsgBox "Click " & X & " " & Y

> End Sub


> > Is there a way to get X and Y values for a mousedown (or click) event
> > on a worksheet (similar to the chart_mousedown event)?

> > The application I'm writing involves a number of jpeg pictures tiled
> > together to form a large image (actually a series of astronomical
> > photographs).  I want the user to be able to click on an object in the
> > photos and have the routine return a message box with information
> > about the coordinates and name etc. of the object.  So far the only
> > way I can do this is to have the user draw a small rectangle over the
> > object, select the rectangle and then have the user manually run a
> > subroutine that uses the .top, .left, .height, .width properties of
> > the rectangle to get the x and y coordinates needed for extracting the
> > data to display to the user)



Tue, 19 Jul 2005 20:18:57 GMT  
 mousedown event on a worksheet?
See Andy Pope's suggestion about using a control toolbox label.  It
will do what you need.

If a toolbox cannot be made transparent, a workaround to get the same
effect is as follows:

In some graphics program (or even in XL) put all the images together
into a single group.  Copy this grouped image into the clipboard (i.e.,
just copy it).

Now, in XL, create a single label large enough to cover the complete
image.

Right-click and select Properties.  In the properties list, select the
contents of Picture property.  Paste.

Double click the label.  Add code for the MouseUp or MouseDown or
MouseMove event(s).

Since you know where each celestial entity is relative to the image
coordinates, mapping XL's X,Y coordinates to the celestial entity
should be straightforward.

--
Regards,

Tushar Mehta (www.tushar-mehta.com) MS MVP -- Excel


Quote:
> You're not missing anything; you detected an error in my choice of
> words.  By "information...about the object" I meant information about
> the astronomical objects (galaxies, quasars, etc.) depicted on the VBA
> object (picture).  For purposes of clarity, I should have referred to
> the galaxies, quasars, etc. as astronomical "entities," not "objects."
>  There can be hundreds of astronomical entities on a single picture.
> The VBA routine I'm writing keeps track of where each picture is on
> worksheet: say the user clicked on a galaxy whose mousedown X and Y
> were (305, 510) and this X,Y was on a picture whose top-left was
> (200,400), then the VBA routine would know that the user wanted info
> on the astronomical entity located at (105, 110)  from the top-left of
> the picture.  The VBA routine (knowing, say, that the scale of the
> picture was 200 VBA X,Y units per degree of sky and knowing the
> location of the picture in the sky) would compute the astronomical
> coordinates of the sky area the user clicked on and then look in
> various worksheets to find astronomical entities near that point and
> return a message box saying, for example, "You just clicked on 3C273,
> a quasar with redshift .156, magnitude 12.86, also classified as a
> Seyfert type 1, blazar, etc etc."


> > I may be missing something, but...

> > For each image, right click on it and select Assign Macro... to assign
> > a macro to run when the user clicks on the image.

> > --
> > Regards,

> > Tushar Mehta (www.tushar-mehta.com) MS MVP -- Excel



> > > Is there a way to get X and Y values for a mousedown (or click) event
> > > on a worksheet (similar to the chart_mousedown event)?

> > > The application I'm writing involves a number of jpeg pictures tiled
> > > together to form a large image (actually a series of astronomical
> > > photographs).  I want the user to be able to click on an object in the
> > > photos and have the routine return a message box with information
> > > about the coordinates and name etc. of the object.  So far the only
> > > way I can do this is to have the user draw a small rectangle over the
> > > object, select the rectangle and then have the user manually run a
> > > subroutine that uses the .top, .left, .height, .width properties of
> > > the rectangle to get the x and y coordinates needed for extracting the
> > > data to display to the user)



Tue, 19 Jul 2005 20:25:41 GMT  
 mousedown event on a worksheet?
Hi Tushar,

Using the Control Toolbox add a label to a worksheet.
Bring up the properties window and set
Backstyle to Transparent
Borderstyle to None

Quote:

> How does one make a control toolbox label (or any other control for
> that matter) transparent with no border?  It must be something trivial,
> but for the life of me, I cannot figure it out.

--

Cheers
Andy

http://www.andypope.info



Tue, 19 Jul 2005 21:40:26 GMT  
 mousedown event on a worksheet?
DUH!  I ignored BackStyle altogether.  Spent (wasted?) my time playing
with BackColor and ForeColor!

--
Regards,

Tushar Mehta (www.tushar-mehta.com) MS MVP -- Excel


says...

Quote:
> Hi Tushar,

> Using the Control Toolbox add a label to a worksheet.
> Bring up the properties window and set
> Backstyle to Transparent
> Borderstyle to None


> > How does one make a control toolbox label (or any other control for
> > that matter) transparent with no border?  It must be something trivial,
> > but for the life of me, I cannot figure it out.



Tue, 19 Jul 2005 23:30:59 GMT  
 mousedown event on a worksheet?
I tried Andy Pope's Label suggestion and it works beautifully.

Thanks to all for your helpful replies.

P.S. Excel works very well for automating the process of tiling large
numbers of high resolution photos into a single image.  At maximum
zoom an Excel spreadsheet has a visible screen area of up to half a
mile wide by three miles long (try doing that in Photoshop!).  If the
photos need to be overlapped, this too can be automated (by drawing
lines connecting identical entities on the overlapping photos, and
then using the coordinates of the lines to precisely automate the
overlapping process, producing a perfect alignment that you could
never get by hand).



Wed, 20 Jul 2005 21:48:01 GMT  
 mousedown event on a worksheet?
Glad you got it all worked out.  Can't help but wonder how the
Photoshophiles would react to XL being better at something -- anything
-- to do with photo editing/alignment <grin>

--
Regards,

Tushar Mehta (www.tushar-mehta.com) MS MVP -- Excel


Quote:
> I tried Andy Pope's Label suggestion and it works beautifully.

> Thanks to all for your helpful replies.

> P.S. Excel works very well for automating the process of tiling large
> numbers of high resolution photos into a single image.  At maximum
> zoom an Excel spreadsheet has a visible screen area of up to half a
> mile wide by three miles long (try doing that in Photoshop!).  If the
> photos need to be overlapped, this too can be automated (by drawing
> lines connecting identical entities on the overlapping photos, and
> then using the coordinates of the lines to precisely automate the
> overlapping process, producing a perfect alignment that you could
> never get by hand).



Fri, 22 Jul 2005 23:55:15 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. mousedown event

2. mousedown event

3. Open a popup from a modal form in Mousedown event

4. test for continuous mousedown event?

5. TreeView MouseDown Event

6. MouseUp/MouseDown Events

7. Newbie: Worksheet event code to new worksheet

8. Firing events with the worksheet activate event

9. event copying worksheet 1 to worksheet 2.....problem

10. MouseDown client coordinate system Office 97


 
Powered by phpBB® Forum Software © phpBB Group