Consulting

Results 1 to 4 of 4

Thread: add image to one slide each with filename as text box above

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    add image to one slide each with filename as text box above

    i have folder with images need to make a ppt with each image in one slide and their filename as a text box above them
    i have tried the below macro but images goes to the top and dont have any text box.
    Hope someone can help me out, have been struggling with this

    Sub insertPics()
    Dim strFolder As String ' Full path to folder
    Dim strName As String
    Dim oPres As Presentation
    Dim osld As Slide
    Dim ocust As CustomLayout
    Dim x As Long
    ' Edit this:
    strFolder = "W:\Personal Folders\Saicharan Sirangi\AA scrpits\Email attachments" 'note the last \
    Set oPres = ActivePresentation
    Set osld = oPres.Slides(oPres.Slides.Count)
    Set ocust = osld.CustomLayout
    strName = Dir$(strFolder & "*.PNG")
    While strName <> ""
        x = x + 1
        With osld.Shapes.AddPicture(strFolder & strName, msoFalse, msoTrue, -1, -1, -1, -1)
            .Line.Visible = True
            .Line.ForeColor.RGB = vbWhite
        End With
        osld.Shapes.Title.TextFrame.TextRange = strName & x
        strName = Dir()
        If strName <> "" Then
            Set osld = oPres.Slides.AddSlide(oPres.Slides.Count + 1, ocust)
            ActiveWindow.View.GotoSlide osld.SlideIndex
        End If
    Wend
    End Sub
    Last edited by Aussiebear; 04-15-2023 at 11:57 AM. Reason: Adjusted the code tags

Tags for this Thread

Posting Permissions

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