Consulting

Results 1 to 3 of 3

Thread: Import Picture With Same Dimensions As Picture Already On Sheet

  1. #1

    Import Picture With Same Dimensions As Picture Already On Sheet

    I am adding an image to Excel, one image is original picture, one is updated picture, I want the original picture to stay in the exact same location, but I want the updated picture to be same heightxwidth and be offset by 4 cells. This is my syntax, but the updated picutre is keeping its height & width not updating to mirror what the original picture has?
    [vba]
    Set image = .Pictures.Insert("C:\" & employeename & "\" & employeename & ".jpg")
    For Each Shape In ActiveSheet.Shapes
    If (Shape.Name = "Old Picture") Then
    Shape.Select
    image.Left = Shape.Left + 30
    image.Top = Shape.Top + 30
    image.Width = Shape.Width
    image.Height = Shape.Height
    End If
    Next
    [/vba]

  2. #2
    Would this work?


        
        Dim a As Long, b As Long
        With ActiveSheet.Shapes("Original Picture")    '<---- Change name as required
            a = .Height
            b = .Width
        End With
    
    
        ' Code to import and place your new picture
    
    
        With ActiveSheet.Shapes("New Picture")    '<---- Change name as required
            .LockAspectRatio = msoFalse
            .Height = a
            .Width = b
        End With

  3. #3
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,642
    or
    Sub M_snb()
       With Shapes("first")
          Shapes.AddPicture "G:\OF\werkblad.gif", 1, -1, .TopLeftCell.Offset(, 4).Left, .Top, .Width, .Height
        End With
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •