Thumbnail/enlarging pictures

T

The Stoat

Hi,

Is it possible to insert a small picture in a cell and have it enlarged when
you 'float' the mouse point over it?

Thanks for any help,

Matt.
 
E

Earl Kiosterud

Matt,

I'm not aware of an automatic way, but I think you can do it with code. If
you're willing to give it a whack, this may get you started:

Use the Control Toolbox toolbar, and put a picture control on the sheet.
Size it for your thumbnail. In the Properties window for it, set the
Picture property to your image.

Now there's a Mouseover event (in the sheet module in the VBE) which fires
endlessly when the mouse moves over your control. But I don't know of an
event that fires when the mouse leaves the control. So instead you may want
to use Mouse Down event (click) instead, which could change the size of the
control. Then the next Mouse Down event would set it back to the thumbnail
size.

If you're willing to go into the VBE, we'll write some code for you. Maybe
this approach will work. We'd find out, I guess. Or someone may have
another approach.
 
E

Earl Kiosterud

Matt,

I just tried a simple piece of code. It works. Go to the VBE (Alt-F11).
If there's not a Project Explorer pane, then open it (View - Project
Explorer). In it, open a window for the sheet your image control is in
(double click its entry in the Project Explorer pane). Paste in the code
below. Get rid of any linefeeds from this post.

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

Const H = 44 ' Thumbnail height
Const W = 81 ' Thumb width
Const FullRatio = 5 ' full size ratio to thumnail size
Static Image1Thumb As Boolean
If Image1Thumb Then ' is it thumb or full size now?
Image1.Height = H * FullRatio
Image1.Width = W * FullRatio
Image1Thumb = False
Else ' it's full size now
Image1.Height = H
Image1.Width = W
Image1Thumb = True
End If
End Sub

If the name of your control is other than Image1, then change the code to
match. Change the Const values to suit. H and W should be set to the
current size of the image when you put it on the sheet. The code could get
that from the picture; this is a real simple version.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top