Looking for help with the following code. Right now it inserts an image from file and sizes it correctly for the cell I want it in. What i need it to do is if Width>Height Rotate the picture 90 degrees then size it correctly for the cell. I am very new to vb and im sure its pretty simple, but i have fooled around with it for a while now and cannot get it to do what i want.
Private Sub CommandButton4_Click()
Dim PicLocation As String
Dim MyRange As String
range("BID.FLOORPLAN").Select
MyRange = Selection.Address
PicLocation = Application.GetOpenFilename("Image Files (*.jpg),*.jpg", , "Select Image File", , "False")
If PicLocation <> "False" Then
ActiveSheet.Pictures.Insert(PicLocation).Select
Else
Exit Sub
End If
With Selection.ShapeRange
.LockAspectRatio = msoTrue
If .Width > .Height Then
.Width = range(MyRange).Width
If .Height > range(MyRange).Height Then .Height = range(MyRange).Height
Else
.Height = range(MyRange).Height
If .Width > range(MyRange).Width Then .Width = range(MyRange).Width
End If
End With
With Selection
.Placement = xlMoveAndSize
.PrintObject = True
End With
End Sub
Bookmarks