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,123,242
Messages
5,600,506
Members
414,385
Latest member
Lioness227

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
Top