Chop picture in VBA?
Charlotte,
I am using 2010, and apparently the method I used is only available in 2010 or later. I spent some time trying to work out a way to do this in 2007. Below is my best effort, but it may not be the best way. Give it a try and see if this works for your needs.
Ben
Sub CropIt()
Dim sShape As Shape
Dim sPicture As Shape
Set sShape = Sheet1.Shapes("Rectangle 1")
Set sPicture = Sheet1.Shapes("Picture 4")
With sPicture.PictureFormat 'Reset picture size, then crop to shape size
.CropBottom = 0
.CropLeft = 0
.CropRight = 0
.CropTop = 0
.CropRight = sPicture.Left + sPicture.Width - sShape.Left - sShape.Width
.CropBottom = sPicture.Top + sPicture.Height - sShape.Top - sShape.Height
.CropLeft = sShape.Left - sPicture.Left
.CropTop = sShape.Top - sPicture.Top
End With
End Sub
|