Moving an inserted picture after it has been cropped

rpolasky

New Member
Joined
Mar 29, 2013
Messages
18
Hello Excel gurus!

My code is:

Code:
Sub Insertwinds1()
ppath = "winds.webimage.url"
With ActiveSheet.pictures.insert(ppath)
.left = Range("A2").left
.top = Range("A2").top
.ShapeRange.PictureFormat.CropRight = 70
.ShapeRange.PictureFormat.Cropleft = 130
.ShapeRange.PictureFormat.CropTop = 300
.ShapeRange.PictureFormat.CropBottom = 90
End With
End Sub

This takes the image from the web (which is fairly large), moves it to Cell A2, and then Crops out the extra space I don't need showing. When this Macro is finished, due to the large Crop size, the image is in the center of the screen and nowwhere near the A2 cell. Is there a simple addition I can add to this code to move it back to a specific cell (a2) after it's been cropped? or move it via placement on the sheet (13, 13, 600, 600)? My old code I was using for this was:

Code:
Dim MYPICTURE As Shape
Set MYPICTURE = Activesheet.shapes.addshape(msoshaperectange, 13, 13, 600, 600)
MyPICTURE.fill.userpicture "winds.webimage.url"
End Sub

This one inserted the image, placed it in the specific spot... but I can't get that one to crop it, which is why I started over with teh first code.

Please Help Me Excel-Wan Kenobi - You're my only hope!

RPolasky
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Crop first and then set left and top?
 
Upvote 0
If this works, I will be happy and say thank you... and then cry because it was so simple.... checking....
 
Upvote 0
That was it! /cry

It cropped it, THEN placed it in the Cell.

Side note: you don't happen to have the additional code to expand the size of it?
 
Upvote 0

Forum statistics

Threads
1,216,151
Messages
6,129,162
Members
449,489
Latest member
spvclub

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