I am trying to create macro which is going to export data from Excel file into Word document with specific conditions. Each row in the table has photos attached - sometimes 1 and sometimes more. I would like to paste text from the table and then the photo below. If my current row has more than 1 photo attached, then I would like to copy the same text to the next page and paste next photo below. As a result I will have 1 photo per page with the description.
For now I have a code which is checking photo's name by counting two first numbers (example: 66_foto1.jpg, 66_foto2.jpg, 67_foto1.jpg) but I am not sure how to copy the text at the begining of the next page.
Part of the code:
Dim fso As Object
Dim objfolder As Object
Dim objfile As Object
Dim lCount As Long 'number of photo starts with 66_
Dim strpath As String
Dim objsub As Object
strpath = "C:\xxx\photos" 'path where photos are located
Set fso = CreateObject("Scripting.FileSystemObject")
Set objfolder = fso.GetFolder(strpath)
For Each objfile In objfolder.Files
If UCase(objfile.Name) Like "66_*" Then lCount = lCount + 1
Next objfile
Dim imagePath As String
For i = 1 To lCount
imagePath = "C:\xxx\photos\" & "66_" & "Foto " & i & ".jpg"
objWord.Selection.InlineShapes.AddPicture Filename:= _
imagePath, LinkToFile:=False, _
SaveWithDocument:=True
objWord.Selection.TypeParagraph
Next
For now there is just photo no. 66, but I would like to make variables and count different ones.