How do I get the image to auto-size?
Here is my code..
Private Sub cmdAddImage_Click()
' inserts a picture and resizes it to fit the TargetCells range
Dim p As Object, t As Double, l As Double, w As Double, h As Double
If Dir(Me.TextBox1.Text) = "" Then Exit Sub
' import picture
Set p = Worksheets("Journey Management").Pictures.Insert(Me.TextBox1.Text)
' determine positions
With Range("B74:H91")
t = .Top
l = .Left
w = .Offset(0, .Columns.Count).Left - .Left
h = .Offset(.Rows.Count, 0).Top - .Top
End With
' position picture
With p
.Top = t
.Left = l
.Width = w
.Height = h
End With
Set p = Nothing
End Sub
Bookmarks