View Single Post
 
Old 04-02-2018, 09:53 PM
laddiator laddiator is offline Windows 10 Office 2016
Novice
 
Join Date: Apr 2018
Posts: 1
laddiator is on a distinguished road
Default Linked Image Cannot Be Displayed

Looks like just a link is being saved when I use this. Did some research and it looks like I need to insert the pictures into a shape instead. Can anyone help me with that?

Here's what I have right now. It works perfectly until I try to send it.

Code:
Sub InsertPictures()
 
    Dim vFilename           As Variant
    Dim oPic                As Picture
    Dim StartRow            As Long
    Dim StartCol            As Long
    Dim NumCols             As Long
    Dim i                   As Long
    Dim r                   As Long
    Dim c                   As Long
    
    vFilename = Application.GetOpenFilename( _
        FileFilter:="Pictures (*.gif;*.jpg;*.png), *.gif;*.jpg;*.png", _
        Title:="Select Picture", _
        MultiSelect:=True) 

    If Not IsArray(vFilename) Then Exit Sub
    
    StartRow = 8 
    StartCol = 1 
    NumCols = 4 
    
    r = StartRow
    c = StartCol
    For i = LBound(vFilename) To UBound(vFilename)
        Set oPic = ActiveSheet.Pictures.Insert(vFilename(i))
            With oPic
            .ShapeRange.LockAspectRatio = msoFalse
            .Left = Cells(r, c).Left
            .Top = Cells(r, c).Top
            .Width = Cells(r, c).Width
            .Height = Cells(r, c).Height
        End With
        
        If i Mod NumCols = 0 Then
            r = r + 2
            c = StartCol
        Else
            c = c + 2
        End If
    Next i
 
End Sub
Thanks!
Reply With Quote