The code to which you link is not particularly robust. I've extracted the assignment to the cell in Excel (ExR(1, 1) = WDR ' place at Excel cursor
) and built more robust Word code around it.
The code uses the Word Range
object instead of Selection
. This is more efficient, more predictable and the screen won't jump around. The Find uses a wildcard search for the specific text, plus the digits between "Length " and " words". Since a successful Find includes the found Range, all that's necessary is to assign the Range's Text to the cell in Excel.
The Find plus assignment is built into a LOOP, which runs as long as Find.Execute is successful. For the cell assignment in Excel a COUNTER is incremented in each loop so you don't need to hard-code the target cell indices.
Dim strFind As String
Dim rngFind As word.Range 'or As Object if you don't set a Reference to the Word object library
Dim bFound As Boolean
Dim iCellCounter As Long
strFind = "Length: [0-9]{1;} words"
bFound = False
iCellCounter = 1
Set rngFind = WApp.ActiveDocument.Content
With rngFind.Find
.ClearAllFuzzyOptions
.ClearFormatting
.ClearHitHighlight
.Format = False
.MatchWildcards = True
.Text = strFind
.wrap = wdFindStop '0 if you don't use a Reference to the Word object library
Do
bFound = .Execute
If bFound Then
ExR(1, iCellCounter) = rngFind.Text
iCellCounter = iCellCounter + 1
End If
Loop While bFound
End With