
Originally Posted by
mrice
Replace Target with Selection as you don't appear to have specified what range Target is?
Yes, you are right, there is another part of the code, like this;
Private Sub CommandButton3_Click()
Dim myPicture As String, MyRange As Range
myPicture = Application.GetOpenFilename _
("Pictures (.bmp; .gif; .jpg; .png; .tif),.bmp; .gif; .jpg; .png; .tif", _
, "Select Picture to Import")
Set MyRange = Selection
InsertAndSizePic MyRange, myPicture
End Sub
Sub InsertAndSizePic(Target As Range, PicPath As String)
Dim p As Picture
Application.ScreenUpdating = False
Set p = ActiveSheet.Pictures.Insert(PicPath)
If Target.Cells.Count = 1 Then Set Target = Target.MergeArea
With Target
p.Left = .Left
p.Width = .Width
End With
End Sub
BUT, after some more research, i have come up with this;
Sub InsertAndSizePic(Target As Range, PicPath As String)
Dim p As Picture
With Selection
Set p = .Parent.Pictures.Paste
p.Top = .Top
p.Left = .Left
p.Width = .Width
End With
End Sub
Thanks your tip led me to investigate...
Bookmarks