Zoom in on an image (picture) displayed in workbook

SerenityNetworks

Board Regular
Joined
Aug 13, 2009
Messages
96
I'm using the following code to display an image in a workbook.
Code:
Sub Image21()
    On Error GoTo ProcExit21
    Dim objPicture As Picture
    With Sheets("Working").Cells(1, 1) ' Picture displays in cell from row, column
        Set objPicture = .Parent.Pictures.Insert(Sheets("Working").Cells(2, gvarImgColumn + 20).Value) ' Picture path row, column
        objPicture.Width = Sheets("Parameters").Cells(83, 2).Value
        'objPicture.Height = Sheets("Parameters").Cells(84, 2).Value
        objPicture.Top = Sheets("Parameters").Cells(85, 2).Value
        objPicture.Left = Sheets("Parameters").Cells(86, 2).Value
        objPicture.Border.Color = RGB(69, 107, 43)
        objPicture.Border.Weight = xlThick
        objPicture.Border.LineStyle = xlContinuous
    End With
ProcExit21:
End Sub
I would like to be able to zoom in on the image. I am not looking to simply make the image bigger; that I can do. I can control contrast and brightness for all images displayed, rotate a single image, and more, but I am not seeing how I can zoom in on a single image.

Is there a way?

Thanks in advance,
Andrew
 
Last edited:

SerenityNetworks

Board Regular
Joined
Aug 13, 2009
Messages
96
I realize I should probably add some detail on the project use. Here is an example:
  • I load four local images into the worksheet using the above code.
  • The user types information regarding the images into cells (not a user form).
  • The user clicks a button. The four images are removed and four new images load.
  • The process repeats.
  • Ideally, I would like for the user to be able to click and drag over an area on one of the images and have that section either appear as a new image on the worksheet or replace the original image.

I've been wondering if I could use the click and drag to define a crop area. Effectively, the cropped image would be a zoom of the original once the crop was set to the same dimensions as the original. I'm not trying to save the new image. I just want to view an area of the original more closely.

I've seen where there are some solid image controls when the image is displayed in a userform, but I'd rather stay away from this method if possible. (Although, if there is no alternative then I'm open to loading the image into a userform, so the zoom is possible.)

Thanks,
Andrew

PS. I can understand and muddle my way around VBA when provided an example, but I'm not a developer by trade. There's not much code that I can write by scratch.
 
Last edited:

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
4,978
Office Version
365
Platform
Windows
Are the 4 images always placed in the same cells as the previous 4 images ?
Are there any other images on this worksheet ?
 
Last edited:

SerenityNetworks

Board Regular
Joined
Aug 13, 2009
Messages
96
The images (pictures) are inserted/displayed in the worksheet. They are not placed in cells. The macro provides the coordinates for where they are displayed.

Thanks.
 

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
4,978
Office Version
365
Platform
Windows
Are there any other images in the worksheet ?
 

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
4,978
Office Version
365
Platform
Windows
The question you asked refers to 4 images - are there any other images in the sheet ?
 

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
4,978
Office Version
365
Platform
Windows
I will post some code tomorrow. (Gone midnight here)

But here is a suggested approach

Add 4 transparent active-X labels
They are placed above the images
Active-X objects have a MouseMove event which can be the required trigger
Zoom is a temporary resizing with mouseover

Are any macros attached to the images ? (Does clicking on an images run a Macro ?)
 

SerenityNetworks

Board Regular
Joined
Aug 13, 2009
Messages
96
Yes. Clicking an image expands it and brings it to the front. This used to be adequate for the user to see the detail needed. But now the pictures have changed and often the detail the user needs to see is too small. Hence the need for the zoom. It would be very good if the zoom could persist while the user types the information into cells, but it's not an absolute requirement.

Thanks!
 

Forum statistics

Threads
1,086,054
Messages
5,387,531
Members
402,069
Latest member
low iq excel user

Some videos you may like

This Week's Hot Topics

Top