Results 1 to 5 of 5

Thread: Coding works for WORD but not POWERPOINT, how should i modify it?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Newbie
    Joined
    Mar 2023
    Posts
    2
    Location

    Coding works for WORD but not POWERPOINT, how should i modify it?

    I would like to insert every 6 pictures in a new slide of powerpoint with it's file name at the centre bottom of the image itself.

    The below coding works for word but not on powerpoint and i would like to do further editing.

    1) modify coding so it'll work on powerpoint as well
    2) current in word it's showing 1 image per page, can we modify to show 6 images per slide when it comes to powerpoint?
    3) the file name in word currently showing the format of the file e.g. jpg / .png, how could i skip that?
    4) the file name is showing on the bottom left in word, how can i make it centre bottom?


    Sub PicWithCaption()
        Dim xFileDialog As FileDialog
        Dim xPath, xFile As Variant
        On Error Resume Next
        Set xFileDialog = Application.FileDialog(msoFileDialogFolderPicker)
        If xFileDialog.Show = -1 Then
            xPath = xFileDialog.SelectedItems.Item(1)
            If xPath <> "" Then
                xFile = Dir(xPath & "\*.*")
               Do While xFile <> ""
                   If UCase(Right(xFile, 3)) = "PNG" Or _
                       UCase(Right(xFile, 3)) = "TIF" Or _
                       UCase(Right(xFile, 3)) = "JPG" Or _
                       UCase(Right(xFile, 3)) = "GIF" Or _
                       UCase(Right(xFile, 3)) = "BMP" Then
                       With Selection
                           .InlineShapes.AddPicture xPath & "" & xFile, False, True
                           .InsertAfter vbCrLf
                           .MoveDown wdLine
                           .Text = xFile & Chr(10)
                           .MoveDown wdLine
                       End With
                   End If
                   xFile = Dir()
                Loop
            End If
        End If
    End Sub
    Last edited by Aussiebear; 03-02-2025 at 04:29 AM. Reason: Added code tags to supplied code

Posting Permissions

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