Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Christchurch, New Zealand
    Posts
    250
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Changing numbered lists to Styles

    I am trying to write a macro that looks at the document and where it finds an automatic numbered list applies a style to the paragraph. This works fine if I want all numbered paragraphs to be the same style. I actually want to look at the indent and based on this determine which style I want to use for each paragraph. I've marked the code that is causing me problems.

    Any ideas would be much appreciated.

    Sub ReplaceNumberWithStyle()
    Dim paraIndent As Single
    Dim numPar
    For Each numPar In ActiveDocument.ListParagraphs

    'doesn't like this line
    paraIndent = numPar.ParagraphFormat.LeftIndent

    Select Case paraIndent
    Case 1 To 36
    numPar.Style = wdStyleHeading1
    Case 37 To 72
    numPar.Style = wdStyleHeading2
    Case Else
    numPar.Style = wdStyleNormal
    End Select

    Next numPar

    End Sub

  2. #2
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing numbered lists to Styles

    Karen,

    Change that line to:
    paraIndent = numPar.Range.ParagraphFormat.LeftIndent
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  3. #3
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts

    Re: Changing numbered lists to Styles

    Hi Karen,

    You may want to contact Dave Rado. I believe that he has been working for some time trying to use VBA to fix numbering.

    Dave maintains the Word MVP site.
    Charles Kyle Kenyon
    Madison, Wisconsin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •