Results 1 to 5 of 5

Thread: How to add image text automatically to images?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    I don't have your exact use case; I helped a person before to add images to a table. I switched it around to also add the file name, which it seems you're doing? (or is the name contained inside the text file?)

    This code loops a folder for all the jpg files, put the image in a table and writes the name of the image file in the associated row

    Private Sub btnAddPictures_Click()
    
    
        Dim tbl As Table
        Set tbl = FindTable("imagesTable", Slide2)
        
        Dim currentTableRow As Integer
        currentTableRow = 1
            
        Dim shp As Shape
        
        Dim imageFileName As String ' add Microsoft Scripting Runtime (in tools > references)
        imageFileName = Dir("F:\PPT_SlideImages\*.jpg")
        
        Do While Len(imageFileName) > 0
            tbl.Cell(currentTableRow, 1).Shape.Fill.UserPicture "F:\PPT_SlideImages\" & imageFileName
            tbl.Cell(currentTableRow, 2).Shape.TextFrame.TextRange.Text = imageFileName
            imageFileName = Dir
            currentTableRow = currentTableRow + 1
        Loop
    
    
    End Sub
    
    
    Private Function FindTable(tblName As String, whichSlide As Slide) As Table
    
    
        Dim shp As Shape
        For Each shp In whichSlide.Shapes
            If shp.HasTable And shp.Name = tblName Then
                ' this is an image and it has logo in the name
                Set FindTable = shp.Table
                Exit Function
            End If
        Next
    
    
    End Function
    Attached Images Attached Images

Posting Permissions

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