Hello,
I have a problem, I'm trying to use this code to add picture/image in wanted cell, in this case at range A51:D66, code works fine but everytime I select picture, it's placed at range A3:D18.
Sub InsertPicture2()
Dim myPicture As Variant
myPicture = Application.GetOpenFilename _
("Pictures (*.gif; *.jpg; *.bmp; *.tif),*.gif; *.jpg; *.bmp; *.tif", , "Select Picture to Import")
If myPicture = False Then Exit Sub
Application.ScreenUpdating = False
Dim iLeft#, iTop#, iWidth#, iHeight#
With Range("A51")
iLeft = .Left
iTop = .Top
.Select
End With
Set myPicture = ActiveSheet.Pictures.Insert(myPicture)
With Range("A51:D66")
iWidth = .Width: iHeight = .Height
End With
With myPicture
.Width = iWidth: .Height = iHeight
End With
Application.ScreenUpdating = True
End Sub
I have a commandbutton that hides/unhides rows 28:66, and row 49 contains button "add picture". Point is that when I unhide rows, "add picture"-button appears, I push it and get to select picture. It does appear but at A3:D18.
I tried it on a blank sheet, picture was placed B5:G20 :p
No matter how large/small image is, code resizes it but at the wrong range :P
Bookmarks