7

I have a Word2010 document that was created by a tool from Axure.

  • Each heading is formated with a custom style ("AxureHeading1", "AxureHeading2", "AxureHeading3").
  • I was able to create a table of contents with the custom made headings: References tab, click Table of Contents, click Insert Table of Contents, and then click Options. Under Available styles.
  • But i am unable to figure out what i need to do to include these custom headings in the navigation pane

What can i do to either

  1. change every custom heading (level 1, 2, 3) with the inbuild headings from word without clicking and selecting each heading manually (VBA Macro?)
  2. or adjust the custom heading style so that it will show up in the navigaton pane

An image of the navigation pane that shows the inbuild headings Navigaton Pane in Word 2010

Update

It seems that my macro approach works (option 1). But if anybody knows a way for option 2 i would still be interested to hear about it.

3 Answers 3

14

VBA isn't required.

In the modify style dialog select FORMAT - PARAGRAPH and change the OUTLINE LEVEL from Body Text to the Outline Level you want.

This will add all the headings with that style to the document document outline shown in the Navigation Pane.

1

Option 1 to replace formating

Using a macro

The following macro changes the heading from one style to another

Sub FindAndReplaceStyle()

Dim intI As Integer
Dim newStyle As String


For intI = 1 To ActiveDocument.Paragraphs.Count

    curStyle = ActiveDocument.Paragraphs(intI).Style

    If curStyle = "AxureHeading1" Then
       Call SetStyle(intI, wdStyleHeading1)

    ElseIf curStyle = "AxureHeading2" Then            
        Call SetStyle(intI, wdStyleHeading2)

    ElseIf curStyle = "AxureHeading3" Then
        Call SetStyle(intI, wdStyleHeading3)

    End If       

Next intI

and to reduce code duplication and increase readability a small helper function

Sub SetStyle(intI, newStyle)

    Dim ranActRange As Range
    Set ranActRange = ActiveDocument.Paragraphs(intI).Range

        With ranActRange               
            ranActRange.Style = newStyle
        End With

End Sub

Using the search replace dialogue

In this article i found that using the inbuild search replace function (CTRL +H) you can pick to search for formatting. I have not tested it yet on my document but i looks promising.

Option 2 Changing the outline level

As Patrick suggested you can change the OUTLINE LEVEL from Body Text to another one. Since my edit on Patricks answer was rejected i included the screenshot in this answer.

Open modify style dialogue

Open modify style dialogue

Select paragraph as the format-object you would like to change

Select paragraph as the format-object you would like to change

Select the outline-level

Select the outline-level

0

The easiest way is to make your top level heading be based on Heading 1 in the New Style (or Modify) dialog.

As long as your custom headings cascade from the top level, then they will show in the Navigation Pane.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .