shapes.addpicture aspect ratio

akashawalker

New Member
Joined
May 2, 2013
Messages
16
Hi to all
i am using the below code to insert a picture in excel. the code works and i get a picture, but i how like to size the picture to a fixe width and maintain the aspect ratio.
Any good suggestions.?


Worksheets("Approval Drawing 1").Shapes.AddPicture _
Filename:=myDir & approvaldrawing1 & T_1, _
linktofile:=msoFalse, savewithdocument:=msoTrue, _
Left:=15, Top:=50, Width:=300, Height:=350


Thanks for you time and collaboration

Akasha walker
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
If you specify -1 for height and width, it will come in in the original dimensions. Setting the width after that should maintain the aspect ratio by default.
 
Upvote 0
but where can i set after the width?
the -1 is a good way, but i would like to make the aspect ratio more automatic.
:)
 
Upvote 0
Like this:

Code:
Dim shp as Shape
set shp = Worksheets("Approval Drawing 1").Shapes.AddPicture(_
Filename:=myDir & approvaldrawing1 & T_1, _
linktofile:=msoFalse, savewithdocument:=msoTrue, _
Left:=15, Top:=50, Width:=-1, Height:=-1)
shp.width = 300
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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