[ad_1]
I am trying to add a line of descriptive text “caption” directly below a photo in word. this repeats multiple times based on how many photos are in a folder. the issue is that the “captions” insert themselves after all the photos instead.
example of what i want:
–Photo–
–caption–
–photo–
–caption–
example of what is happening:
–photo–
–photo–
–caption–
–caption–
I think the issue is coming from the “with loop but I cant think how it would print out like that.
the code below is looped from a different method:
Private Sub PlaceImageToTableDefault(Optional realLocation As String = "")
'set up the proper integers and strings to output the picture
Dim ImagePath As String
Dim pic As Bitmap
Dim tableRow As Integer = Row + 1
Dim tableCol As Integer = Col + 1
'determine the location (where to find the picture)
If realLocation.Length > 0 Then
ImagePath = realLocation
Else
ImagePath = alteredImageSave
End If
pic = New Bitmap(ImagePath)
'makes sure that the output is correct when there are no folders
If numOfGroups <> 0 Then
oTable.Cell(tableRow, tableCol).Range.Text = vbCr & caption
End If
'put image into the "table" in word as well as putting the caption below the image
With oTable.Cell(tableRow, tableCol).Range
.InlineShapes.AddPicture(ImagePath)
.InsertParagraphAfter()
.InsertAfter(caption)
.InsertParagraphAfter()
End With
'change the size of the inserted image
ResizePlacedImage(alteredBMP)
end sub
[ad_2]