O
osirun
So what I'm trying to do is loop through all the frames in my
document, and see if they're on the same page as text with the style
"Heading 2". Here's the code:
Dim SrcRg As Range
Dim frm As frame
Set SrcRg = ActiveDocument.Range
For Each frm In ActiveDocument.Frames
With SrcRg.Find
..ClearFormatting
..Text = ""
..Format = True
..Style = ActiveDocument.Styles("Heading 2")
..Forward = True
..Wrap = wdFindStop
Do While .Execute
If SrcRg.Information(wdActiveEndAdjustedPageNumber) =
frm.Range.Information(wdActiveEndAdjustedPageNumber) Then
MsgBox SrcRg.Information(wdActiveEndAdjustedPageNumber)
Exit Do
End If
Loop
End With
Next
What I'd like this to do is loop through all the frames, and for each
one search through all the Heading 2's and, if it finds one on the
page that the frame is on, print out a message box accordingly. In
practice, it just prints out the first page that has a frame and a
Heading 2 on... and that's it.
Can anyone smart tell me what's going on here?
document, and see if they're on the same page as text with the style
"Heading 2". Here's the code:
Dim SrcRg As Range
Dim frm As frame
Set SrcRg = ActiveDocument.Range
For Each frm In ActiveDocument.Frames
With SrcRg.Find
..ClearFormatting
..Text = ""
..Format = True
..Style = ActiveDocument.Styles("Heading 2")
..Forward = True
..Wrap = wdFindStop
Do While .Execute
If SrcRg.Information(wdActiveEndAdjustedPageNumber) =
frm.Range.Information(wdActiveEndAdjustedPageNumber) Then
MsgBox SrcRg.Information(wdActiveEndAdjustedPageNumber)
Exit Do
End If
Loop
End With
Next
What I'd like this to do is loop through all the frames, and for each
one search through all the Heading 2's and, if it finds one on the
page that the frame is on, print out a message box accordingly. In
practice, it just prints out the first page that has a frame and a
Heading 2 on... and that's it.
Can anyone smart tell me what's going on here?