![]() |
|
#2
|
||||
|
||||
|
Because your document has been produced by a process that uses frames to position the text instead of placing the text directly onto the page, there is no 100% reliable way of doing this. That said, the following seems to work with your attachment.
Code:
Sub GetGrandTotals()
Dim Sctn As Section, Frm As Frame, x As Long, v As Single
With ActiveDocument
For Each Sctn In .Sections
With Sctn.Range
v = 0
For x = 1 To .Frames.Count
With .Frames(x)
If .Range.Text = "Grand Total" Then
v = .VerticalPosition - 7.25: Exit For
End If
End With
Next
For x = 1 To .Frames.Count
With .Frames(x)
If .VerticalPosition = v Then MsgBox .Range.Text: Exit For
End With
Next
End With
Next
End With
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Word is not being able to find/replace a specific color | jaumzaum | Word | 3 | 07-08-2021 09:09 AM |
Macro to check the existence of a word docx file and create a new word file with specific content.
|
staicumihai | Word VBA | 14 | 11-15-2016 01:42 AM |
needles and haystacks – how to find that one .doc file containing a specific word? Windows 7
|
eNGiNe | Windows | 7 | 04-02-2015 05:05 AM |
| needles and haystacks – how to find that one .doc file containing a specific word? Windows 7 | eNGiNe | Word | 0 | 04-01-2015 11:15 PM |
| How to find a specific word in Powerpoint? | Ozard80 | PowerPoint | 0 | 05-11-2011 04:42 PM |