inserting picture but need the aspect ratio to not control the size

judgejustin

Board Regular
Joined
Mar 3, 2014
Messages
150
I have a form that requires pictures to be placed in it. I have added a button and assigned the following macro to set the size and placement of the picture I need. It works great, except the height does not fit correctly. It seems the height is being controlled by the aspect ratio of the pictures. The pictures are all in different original dimensions and each time one is selected it will appear in the correct place with the correct width but not the correct height.
Am I missing something? Can someone, that is much better than I am, give me a suggestion?
It may not be the aspect ratio that is just the only thing that seems to make sense to me.
Thanks



Sub Button1_Click()
Dim myFiles, e
myFiles = Application.GetOpenFilename(, , , , True)
If Not IsArray(myFiles) Then Exit Sub
For Each e In myFiles
With ActiveSheet
With .Pictures.Insert(e)
.Left = Range("a1:a15").Left
.Top = Range("a1:f1").Top
.Height = Range("a1:a15").Height
.Width = Range("a1:f1").Width
End With
End With
Next
End Sub
 
Yes, I believe you'll need to set the LockAspectRatio property to False. Try adding the following line of code prior to setting the properties...

Code:
.ShapeRange.LockAspectRatio = False

Hope this helps!
 
Upvote 0

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