Hello,
i have a nice worksheet, where i can import pictures and zoom them out and in on a click. But, is there a way to zoom the pictures out bgger than their size in the same folder -> for example the are imported into cells d25 to j25 if you set the name of the pictures from cells d24 to j24.
after clicking, these pics will be zoomed out to their picture size. I cannot set the zoom taller than this. Is there a way to do this in my code - for example 2 times bigger?
Stef
Zoom Picture in and out
-
- 4StarLounger
- Posts: 415
- Joined: 29 Mar 2010, 11:50
- Location: Vienna, Austria
Zoom Picture in and out
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78595
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Zoom Picture in and out
Change the lines
to for example
Code: Select all
bu = Range(rng).Width
su = Range(rng).Height
Code: Select all
bu = 2 * Range(rng).Width
su = 2 * Range(rng).Height
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 415
- Joined: 29 Mar 2010, 11:50
- Location: Vienna, Austria
Re: Zoom Picture in and out
Hi Hans, thanks for the quick answer, but this is, what i tried. It enlarges the picture to double size, but prevents from reducing to its original size after the zoomiong out.
best regards,
Stef
best regards,
Stef
-
- Administrator
- Posts: 78595
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Zoom Picture in and out
To what size should the pictures be reduced? This is what I get (you didn't bother including the images):
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 415
- Joined: 29 Mar 2010, 11:50
- Location: Vienna, Austria
Re: Zoom Picture in and out
when you import the picture first, it is set to the cell size - that is , what should be the "origin" size. when you click, it zoomes out to its size (if you open it in paint or so) - for example, the size of the first picture - Beschaffung.jpg is 361 KB (2325 Pixel - Horizontal , 2425 -Vertical Pixel)...
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78595
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Zoom Picture in and out
Try this:
Code: Select all
Sub ViewPicture()
Dim shp As Shape, rng As Range
Set shp = ActiveSheet.Shapes(Application.Caller)
Set rng = shp.TopLeftCell
If shp.Width = rng.Width Then
With shp
.LockAspectRatio = msoFalse
.Height = 2 * rng.Height
.Width = 2 * rng.Width
.ZOrder msoSendToBack
End With
Else
With shp
.LockAspectRatio = msoFalse
.Height = rng.Height
.Width = rng.Width
.ZOrder msoBringToFront
End With
End If
End Sub
Best wishes,
Hans
Hans
-
- NewLounger
- Posts: 1
- Joined: 28 Jan 2021, 17:58
Re: Zoom Picture in and out
Hi,
review this tutorial about image zoom: https://eksi30.com/insert-picture-in-ce ... ell-value/
review this tutorial about image zoom: https://eksi30.com/insert-picture-in-ce ... ell-value/
You do not have the required permissions to view the files attached to this post.
-
- 4StarLounger
- Posts: 563
- Joined: 27 Jun 2021, 10:46
Re: Zoom Picture in and out
Er ... that seems to be exactly the example code Stef is using ...
-
- 4StarLounger
- Posts: 563
- Joined: 27 Jun 2021, 10:46
Re: Zoom Picture in and out
Use ScaleHeight and ScaleWidth instead
Code: Select all
With shp
.LockAspectRatio = msoFalse
.ScaleHeight 2, msoTrue ' Twice height
.ScaleWidth 2, msoTrue ' twice width
.ZOrder msoSendToBack
End With
-
- 4StarLounger
- Posts: 415
- Joined: 29 Mar 2010, 11:50
- Location: Vienna, Austria
Re: Zoom Picture in and out
There is even the reference to eksi30 in it.