• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Add Pictures to file placement error

Teoman

New Member
Hi,

The code below was working fine.

Code:
Sub ResimYerlestirembed()
    Dim Pshp As Shape
    Dim XRg As Range
    Dim xCol As Long
    On Error Resume Next
    Application.ScreenUpdating = False
    Set Rng = ActiveSheet.Range("H3:H5")
    For Each cell In Rng
        urladreshucre = cell
        ActiveSheet.Shapes.AddPicture(urladreshucre, False, True, 100, 100, -1, -1).Select
        Set Pshp = Selection.ShapeRange.Item(1)
        If Pshp Is Nothing Then GoTo lab
        xCol = cell.Column + 1
        Set XRg = Cells(cell.Row, xCol)
        With Pshp
            .LockAspectRatio = True
            .Width = 100
            .Height = 100
            .Top = XRg.Top
            .Left = XRg.Left
        End With
lab:
    Set Pshp = Nothing
    Range("A2").Select
    Next
    Application.ScreenUpdating = True
End Sub

It is expected to embed images starting from I3 but unfortunately, the result is floating images.

The answer should be very simple :(
 
Sorry for unclear question.

Floating means images appear in other cells in proper order not where I want. Also not fitting the cell
 
Hi !

try to replace the codeline Set XRg = Cells(cell.Row, xCol)

by this one : Set XRg = cell(1, 2) … If same result, just check your logic.
 
Do you have the window zoom set to anything other than 100%? That can cause issues with programmatic positioning of shapes.
 
Back
Top