View Single Post
 
Old 12-08-2022, 02:35 PM
macropod's Avatar
macropod macropod is offline Windows 10 Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,479
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote