Ben Adams
Ben Adams

Reputation: 564

How do I find a sibling of a word range in vba?

I am using vba to access a word document. I am iterating through all InlineShapes in the document in order to extract the images. Below all images is a text that describes the image. I want to extract the text for each image so I can combine each image with the text below the image.

How do I find the paragraph that is directly after the InlineShape?

Upvotes: 0

Views: 236

Answers (1)

Bruno Leite
Bruno Leite

Reputation: 1477

You can use

Sub FindIShapes()
    Dim ishp As InlineShape

    For Each ishp In ActiveDocument.InlineShapes
           ishp.Select
           Selection.MoveDown Unit:=wdLine, Count:=1

           Debug.Print Selection.Range.Text

    Next ishp

End Sub

These sub find all iShapes in activedocument, move selection to down and print a text.

[]´s

Upvotes: 0

Related Questions