PDA

View Full Version : VB Inserting image to specific cell in excel



Stobor
01-01-2011, 07:30 AM
Sorry if i selected the wrong forum section, first time visiting this forum.

Heres the problem , i use

Sub test()

Range("a10").Select
ActiveSheet.Pictures.Insert("D:\Users\Guk\Pictures\ggg.jpg").Select

End Sub

but top left corner of the image ggg is not in a10 cell , doesnt matter what coordinates i type in range , images top left corner is always in B4

Thanks for the help

mdmackillop
01-31-2011, 12:02 PM
Welcome to VBAX. A couple of options

Dim pth As String, shpPic As Shape
pth = "C:\AAA\"
pic = "Test.jpg"
Set shpPic = ActiveSheet.Shapes.AddPicture(pth & pic, msoTrue, msoFalse, 0, Cells(10, 1).Top, 100, 100)


or
ActiveSheet.Pictures.Insert("C:\AAA\test.JPG").Select
With Cells(10, 1)
Selection.Top = .Top
Selection.Left = .Left
End With

kimmysun
08-06-2012, 08:10 PM
doesnt matter what coordinates i type in range , images top left corner is always in B4

doesnt matter what coordinates i type in range , images top left corner is always in B4