Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    London, Gtr London, England
    Posts
    416
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Searching for styles (WORD 97/2000)

    Hi,

    Is there a way for searching for a particular style in document (say 'Heading 1") in a loop and if found, check if the heading is an Appendix. Then remove the numbering for that particular chapter.

    I have tried using the Word Macro feature but does not quite work.

    Thanks for any inputs and solutions.

    Robie
    Thanks.
    Robie

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Searching for styles (WORD 97/2000)

    Recording the macro takes you a long way:

    <pre>Sub Appendectomy()
    '
    ' Macro recorded 1/30/2002 by Jefferson Scher
    '
    Selection.Find.ClearFormatting
    Selection.Find.Style = ActiveDocument.Styles("Heading 1")
    Selection.Find.ParagraphFormat.Borders.Shadow = False
    With Selection.Find
    .Text = ""
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    <font color=blue>'see next line</font color=blue> Selection.Find.Execute
    <font color=blue>Do While Selection.Find.Execute()
    'your code to check the heading and stop the numbering goes here
    Loop</font color=blue>
    End Sub</pre>

    Now certainly this is an inefficient way to reference the find object, and you'll want to make sure to start at one end of the document, but now at least you have a loop.

    Next step is to figure out exactly how to determine what is an Appendix...

  3. #3
    Lounger
    Join Date
    Jan 2001
    Location
    Milton Keynes, Buckinghamshire, England
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Searching for styles (WORD 97/2000)

    Robie,

    Our approach to this situation, where we have headings in our prelims or end matter that are the same as the numbered Heading 1 styles in the body of the document except that they are not numbered, is to create a user-defined style for them, say Heading A.

    The Heading A style is based on Normal (not on Heading 1) but is specified with the same formatting as Heading 1 - with the exception of the numbering, of course - and an Outline level of Level 1 so that it is picked up in the Table of Contents in the same way as Heading 1. (Similarly, we define a Heading B style that is "equivalent" to Heading 2.)

    If your Appendix headings are distinguished by containing the word "Appendix" then you can use a Find and Replace to change them all to un-numbered headings (styled with Heading A).

    In the Find what: box enter "Appendix" (without the quotes) and specify a style of Heading 1.

    In the Replace with: box enter ^& and specify a style of Heading A

    If the matter of deciding whether the heading belongs to an Appendix requires a more sophisticated test, then you will need to use to a macro, as Jefferson Scher has already suggested.

  4. #4
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    London, Gtr London, England
    Posts
    416
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Searching for styles (WORD 97/2000)

    THANKS a bunch (both of you). It is exactly waht I was looking for.

    Once again thanks very much.
    Thanks.
    Robie

Posting Permissions

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