Search code examples
powerpoint

How would I embed an image in a PowerPoint 2016 table cell?


I would like to create a 7 column by 5 row table of JPG images a PowerPoint slide.

If I create a table in PowerPoint and insert an object from a JPG file, the image floats over the table.

Is there a way to put an image into a table cell in PowerPoint 2016?


Solution

  • If the image is in the same aspect ratio as the cell you mean to fill, or if you don't mind the image getting distorted if the aspect ratios don't match, fill the cell with the picture.

    Sub TestIt()
    
        Dim oTbl As Table
        Set oTbl = ActivePresentation.Slides(1).Shapes(3).Table
        Call FillCellWithPicture(oTbl, 4, 2, "c:\temp\picture.jpg")
    
    End Sub
    
    Sub FillCellWithPicture(oTable As Table, lCol As Long, lRow As Long, sPicture As String)
        oTable.Cell(lRow, lCol).Shape.Fill.UserPicture (sPicture)
    End Sub