Copying a portion of a picture

Puertorekinsam

Active Member
Joined
Oct 8, 2005
Messages
287
I have another odd request that I hope someone out there can help me with.

is there a way in VBA to copy a portion of an image to the clipboard?

I have an image that appears on multiple tabs of my workbook, and I was able to use one JPEG on a hidden tab and load the image into an image box on the various tabs during worksheet activate and then clear them out when the tab deactivated. This worked great for decreasing file size.

Now I would like to use a simmilar process to take a map of my store (Luckily a large square location) and copy out just a section of the map to put in an image box.

I would think some sort of case statement to determin the top, left, width and height of the section of the image to be coppied would be needed. but I'm not sure if it can be done.

Thanks!
 

Some videos you may like

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Puertorekinsam

Active Member
Joined
Oct 8, 2005
Messages
287
Was able to solve this by using a the crop commands

If nodot = False Then
PercentToCropb = (34 - topcrop) / 34
PercentToCropt = (topcrop - 1) / 34
Set shapeToCrop = Sheet100.Shapes("TheLedge")
With shapeToCrop.Duplicate
.ScaleHeight 1, True
origHeight = .Height
cropPoints = origHeight * PercentToCropb
.PictureFormat.CropBottom = cropPoints
cropPoints = origHeight * PercentToCropt
.PictureFormat.CropTop = cropPoints
.Name = "TempPic"
End With
End If
 

Watch MrExcel Video

Forum statistics

Threads
1,118,662
Messages
5,573,480
Members
412,533
Latest member
Pejter
Top