Macro To Zoom A Picture

rockyw

Well-known Member
Joined
Dec 26, 2010
Messages
1,196
Office Version
  1. 2010
Platform
  1. Windows
I found this macro that will zoom a picture; the problem is it never returns to the original size. Can this or a different macro zoom a picture, and then return the image to the original size after you click off? Or zoom if you hover over an image. I also may have the sheet protected, will it still work then? Thanks for any advice.

Code:
[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Sub Picture_Click()
Set Shp = ActiveSheet.Shapes(Application.Caller)
Shp.Select
ActiveWindow.Zoom = 75
End Sub[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
 
Here's an alternative method, which uses the AlternativeText property of the Shape object to keep track of the zoom position...

1) Enter the following code in a regular module (Alt-F11 > Insert > Module)...

Code:
Option Explicit

Private Sub ZoomInAndOut()

    Dim Shp As Shape
    
    Set Shp = ActiveSheet.Shapes(Application.Caller)
    
    If Shp.AlternativeText = "150% Zoom" Then
        Shp.ScaleHeight 2 / 3, msoFalse
        Shp.ScaleWidth 2 / 3, msoFalse
        Shp.AlternativeText = "100% Zoom"
    Else
        Shp.ScaleHeight 1.5, msoFalse
        Shp.ScaleWidth 1.5, msoFalse
        Shp.AlternativeText = "150% Zoom"
    End If

End Sub

2) For each shape/picture on any sheet within the workbook, assign the above macro by right-clicking on the shape/picture, selecting 'Assign Macro', entering the macro name, and clicking OK. So, for example, if the above macro has been placed in Module1, the macro name should be entered as Module1.ZoomInAndOut

Hope this helps!
 
Upvote 0

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
i know a lot of time has passed since last post but a nice addition to he code would be to make zoomed images go to the front. so if you have a lot of images together when you zoom the images goes to the front so is completely visible
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,687
Members
449,117
Latest member
Aaagu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top