Check whether built-in heading 1 is outline numbered

A

andreas

Dear Experts:
Below code searches for the first occurrence of the built-in
paragraph style heading 1.

Is it also possible to check whether the heading 1 level is outline
numbered, such as
"1 Analysis" ?

Help is much appreciated. Thank you very much in advance.

Regards, Andreas


Sub SearchStyleHeading1

Set rng = ActiveDocument.range
With rng.Find
.Style = ActiveDocument.Styles(wdStyleHeading1)
' Search from Beginning of Document
.Forward = True
'Find only one occurrence
.Wrap = wdFindStop
.Format = True
If .Execute() Then
MsgBox " Heading 1 style in current document!"
End If
End With
End Sub
 
H

Helmut Weber

Hi Andreas,

maybe like that:

Sub SearchStyleHeading1()
Dim rng As Range
Set rng = ActiveDocument.Range
With rng.Find
.Style = ActiveDocument.Styles(wdStyleHeading1)
' Search from Beginning of Document
.Forward = True
'Find only one occurrence
.Wrap = wdFindStop
.Format = True
If .Execute() Then
If rng.ListFormat.ListType = wdListOutlineNumbering Then
MsgBox "outline numbered"
End If
End If
End With
End Sub

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 
A

andreas

Hi Andreas,

maybe like that:

Sub SearchStyleHeading1()
Dim rng As Range
Set rng = ActiveDocument.Range
With rng.Find
   .Style = ActiveDocument.Styles(wdStyleHeading1)
        ' Search from Beginning of Document
        .Forward = True
        'Find only one occurrence
        .Wrap = wdFindStop
        .Format = True
        If .Execute() Then
            If rng.ListFormat.ListType = wdListOutlineNumbering Then
              MsgBox "outline numbered"
            End If
         End If
    End With
End Sub

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP

Hey Helmut,

great, this did the trick.Thank you very much. Regards, Andreas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top