Resizing pictures already pasted to cells

jharlin

New Member
Joined
Feb 26, 2019
Messages
2
I have pictures already pasted into excel cells. I just want to write a macro that will let me change their sizes when I select them. I don't want to paste any new ones and everything I try gives me a 438 error object doesn't support this.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Try
- selecting a picture
- record a macro
- resize picture
- stop recording
- look at the macro
- it provides usable code.

Code:
Dim shp As Object: Set shp = Selection.ShapeRange
[I][COLOR=#006400]'position at top left of cell D5[/COLOR][/I]
    With Range("D5")
           shp.Top = .Top
           shp.Left = .Left
    End With
[I][COLOR=#006400]'should proportions stay the same? (default is msoTrue)[/COLOR][/I]
    shp.LockAspectRatio = msoTrue
    shp.LockAspectRatio = msoFalse
[COLOR=#006400][I]'set height and width like this[/I][/COLOR]
    shp.Width = 200
    shp.Height = 140
[I][COLOR=#006400]'to make width 50% of current width[/COLOR][/I]
    shp.ScaleWidth 0.5, msoFalse, msoScaleFromTopLeft
[I][COLOR=#006400]'to make height 3 times size of current height[/COLOR][/I]
    shp.ScaleHeight 3, msoFalse, msoScaleFromTopLeft
 
Last edited:
Upvote 0
Thank you. I thought about just recording a macro but didn't. However you are right it does produce code I can replicate for my other pictures. I have over 400 on here to do. I appreciate your help.
 
Upvote 0
I have over 400 on here to do

400 pictures??

If you explain what needs doing to the pictures it is likely that more of the process can be automated via VBA
- for example VBA could loop through all the photos on a sheet to avoid each one being selected manually
- perhaps several could be selected and code applied in a loop
etc ..
 
Upvote 0

Forum statistics

Threads
1,214,394
Messages
6,119,263
Members
448,881
Latest member
Faxgirl

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