Need to zoom to a user selected area of an image.

dyates3

New Member
Joined
Apr 30, 2019
Messages
2
I have an image open in a form. The user needs to select a section of the image by drawing a rectangle and zoom to that area.

I've got it working with scroll bars and command buttons but it's not elegant. A lot of clicking and sliding.

I could do it using Shapes etc but am hoping there is something in the library that will make my life easier.

Thanks in advance
D
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
.
If you are ok with a macro run by a command button :

Code:
Option Explicit


Sub ZoomToRange(ByVal ZoomThisRange As Range, ByVal PreserveRows As Boolean)


Dim Wind As Window


Set Wind = ActiveWindow
Application.ScreenUpdating = False
'
' Put the upper left cell of the range in the top-left of the screen.
'
Application.Goto ZoomThisRange(1, 1), True


With ZoomThisRange
    If PreserveRows = True Then
        .Resize(.Rows.Count, 1).Select
    Else
        .Resize(1, .Columns.Count).Select
    End If
End With


With Wind
    .Zoom = True
    .VisibleRange(1, 1).Select
End With


End Sub

'Command button to run this macro. User selects range then clicks the button.
'Works with a sheet range .. hopefully it can be modified for an image ... unless the image is loaded to a sheet ... it should work.


Sub zoomIt()
ZoomToRange ZoomThisRange:=Selection, PreserveRows:=True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,431
Members
452,326
Latest member
johnshaji

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