Results 1 to 2 of 2

Thread: newbie question

  1. #1
    New Lounger
    Join Date
    Mar 2001
    Location
    Austin, Texas, USA
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    newbie question

    I'm trying to find paragraphs formatted with outline numbering and then insert a "hidden" paragraph mark at the beginning (paragraph mark where the font = hidden and red). Everything is working, except for the formatting part. I can't figure out how to do this for the life of me! Any suggestions would be greatly appreciated. (If I need to clarify, please let me know...)

    Sub MarkNumberedParas()
    Dim vPara As Paragraph
    Set pRange = ActiveDocument.Range

    For Each vPara In pRange.Paragraphs
    If vPara.Range.ListFormat.ListType = wdListOutlineNumbering Then
    vPara.Range.InsertBefore Chr(13)
    End If
    Next vPara

    End Sub

    Thanks so much!

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: newbie question

    From my cursory glance at the macro you provided, I would assume that it is not working because your act of inserting an object that is used in the count (a paragraph) confuses the count value and then all hell breaks loose.

    A method to get around this - as often used by WMVP Gary - is shown below. This works because you are counting in reverse and the paragraphs you are adding become the current object after you add them. Don't try to get cute and use a With Para(i) to pretty up the code. For this macro to succeed you will need to create a style in the document with the name HiddenText and the attributes you desire before running the macro.
    <pre>Sub MarkNumberedParas()
    Dim iPara As Double, i As Double
    iPara = ActiveDocument.Paragraphs.count
    For i = iPara To 1 Step -1
    If ActiveDocument.Paragraphs(i).Range.ListFormat.List Type _
    = wdListOutlineNumbering Then
    ActiveDocument.Paragraphs(i).Range.InsertBefore vbCr
    ActiveDocument.Paragraphs(i).Style = ActiveDocument.Styles("HiddenText")
    End If
    Next i
    End Sub</pre>

    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

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