A
andreas
Dear Experts:
Below macro checks whether a user-defined heading style (Heading_IV)
has been applied. If so, it shows the section number of the first
occurence of the custom-defined heading style (Heading_IV) as well as
the corresponding page number of the first occurrence.
It is working fine.
BUT I also would like the MsgBox to show me
.... (1) the text of the first occurrence of this user-definded
heading style (Heading_IV) and ...
.... (2) the paragraph number of the first occurence of this user-
defined heading style (the counting to begin from the section where
the first occurrence of the user-defined heading style has occurred)
Help is very much appreciated. Thank you very much in advance.
Kind Regards, Andreas
Sub FirstOccurrenceUserDefinedHeaderStyle()
Dim rng As range
Dim oRange_Heading_IV As range
Dim nSection_Heading_IV As Long
Dim iPageStart As Integer
Set rng = ActiveDocument.range
With rng.Find
.Style = ActiveDocument.Styles("Heading_IV")
.Forward = True
.Wrap = wdFindStop
.Format = True
If .Execute() Then
iPageStart = rng.Information(wdActiveEndPageNumber)
Set oRange_Heading_IV = rng
nSection_Heading_IV = rng.Sections(1).Index
MsgBox "The first occurrence of HeadingIVis found on
page " & iPageStart & " and Section " & Section_Heading_IV & "."
......
......
Below macro checks whether a user-defined heading style (Heading_IV)
has been applied. If so, it shows the section number of the first
occurence of the custom-defined heading style (Heading_IV) as well as
the corresponding page number of the first occurrence.
It is working fine.
BUT I also would like the MsgBox to show me
.... (1) the text of the first occurrence of this user-definded
heading style (Heading_IV) and ...
.... (2) the paragraph number of the first occurence of this user-
defined heading style (the counting to begin from the section where
the first occurrence of the user-defined heading style has occurred)
Help is very much appreciated. Thank you very much in advance.
Kind Regards, Andreas
Sub FirstOccurrenceUserDefinedHeaderStyle()
Dim rng As range
Dim oRange_Heading_IV As range
Dim nSection_Heading_IV As Long
Dim iPageStart As Integer
Set rng = ActiveDocument.range
With rng.Find
.Style = ActiveDocument.Styles("Heading_IV")
.Forward = True
.Wrap = wdFindStop
.Format = True
If .Execute() Then
iPageStart = rng.Information(wdActiveEndPageNumber)
Set oRange_Heading_IV = rng
nSection_Heading_IV = rng.Sections(1).Index
MsgBox "The first occurrence of HeadingIVis found on
page " & iPageStart & " and Section " & Section_Heading_IV & "."
......
......