Find paragraph and go to the next paragraph after that

J

john smith

Hi,

I'd like to build VBA word Macro to find a particular paragraph/sentence
like "overview test for test specification." and go to the next paragraph
after that to grab the value of the 2nd paragraph to a variable.

How do I find a particular sentence like that? I use selection.find.text but
it's not working. Please help me...

Thank you so muchhh,
John
 
G

Greg Maxey

Try:

Sub Scratchmacro()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "overview test for test specification"
If .Execute Then
oRng.Move wdParagraph, 1
oRng.Expand wdParagraph
ActiveDocument.Variables("myText").Value = oRng.Text
End If
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top