Reputation: 13800
I'm trying to do what it says in the title. My Sub includes this:
Set oPic = oSld.Shapes.AddPicture(FileName:=strPath & strTemp, _
LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, _
Left:=35, _
Top:=260, _
Width:=-1, _
Height:=245)
oPic.LockAspectRatio = msoCTrue
oPic.Height = 255
But for some reason, the aspect ratio is not actually locked - the image height is being reduced to 255 points, but the width stays the same. Any ideas what I'm getting wrong?
Upvotes: 3
Views: 2963
Reputation: 786
Use
oPic.LockAspectRatio = msoTrue
Not, msoCTrue
I can recreate your problem using your code, and I can get the picture to behave by not specifying the height when I load the picture:
Set oPic = oSld.Shapes.AddPicture(FileName:=strPath & strTemp, _
LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, _
Left:=35, _
Top:=260, _
Width:=-1, _
Height:=-1)
oPic.LockAspectRatio = msoTrue
oPic.Height = 255
It looks like the aspect ratio is coming from the picture data -- not from your current scaling of the picture. If this still doesn't achieve what you need, I can see 2 paths:
Update your picture file to meet the aspect ratio you really need, and then use the method above.
Programmatically set the aspect ratio you want by calculating height/width and setting them instead of using .lockaspectratio.
Upvotes: 4