Hello everyone,
I am writing a VBA code in order to insert an image in a specific cell. everything works properly except the horizontal position; no matter what cell I define in the code, it always appear a bit to the left. can someone please tell me what's wrong? Thank you in advance!
here is the code:
Dim path As Variant
Dim pic As Variant
path = Application.GetOpenFilename
If path = False Then Exit Sub
Set pic = ActiveSheet.Pictures.Insert(path)
With pic.ShapeRange
'Resize Picture to fit in the range....
.Left = Range("k1").Left
.Top = Range("k1").Top
.Width = Range("k1:m1").Width
.Height = Range("k1:k3").Height
End With
pic.Placement = xlFreeFloating
pic.PrintObject = True
I am writing a VBA code in order to insert an image in a specific cell. everything works properly except the horizontal position; no matter what cell I define in the code, it always appear a bit to the left. can someone please tell me what's wrong? Thank you in advance!
here is the code:
Dim path As Variant
Dim pic As Variant
path = Application.GetOpenFilename
If path = False Then Exit Sub
Set pic = ActiveSheet.Pictures.Insert(path)
With pic.ShapeRange
'Resize Picture to fit in the range....
.Left = Range("k1").Left
.Top = Range("k1").Top
.Width = Range("k1:m1").Width
.Height = Range("k1:k3").Height
End With
pic.Placement = xlFreeFloating
pic.PrintObject = True