I am able to add multiple images to a word document using VBA, but I am not able to add captions for multiple images loaded from folder path.
Can you please suggest on this:
Sub checking()
Dim strFolderPath
strFolderPath = "C:\images"
Dim objWord
Dim objDoc
Dim objSelection
Dim objShapes
Dim objFSO
Dim objFolder
Set objWord = CreateObject("Word.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strFolderPath)
Set objDoc = objWord.Documents.Open("D:\myfile.docx")
objWord.Visible = True
Set objSelection = objWord.Selection
For Each Img In objFolder.Files
ImgPath = Img.Path
objSelection.InlineShapes.AddPicture (ImgPath)
objSelection.InsertBreak
Next
End Sub