Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Feb 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Headings and subheadings (Office XP - SP1)

    Hi,

    I was wondering if the following would be possible and if so, if there is an easy way to implement it.

    I have a rather large document which is made up of 5 headings. Each heading has about 20 sub headings.
    Now in this sprawling mass of headings it is quite difficult to remember which section one is in. So what I was hoping to do was to
    have heading 4 appended (in small) by heading 3.

    In otherwords I would have
    1.1.1.1 This is heading 4 (heading 3)

    The (heading 3) would be in small. Now I know I could put a cross reference on each heading manually, but this could end up being rather a cumbersome task, so I was hoping that there was someway I could make it simpler!

    Any tips would be much appreciated.

    Regards
    Drumbo

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Headings and subheadings (Office XP - SP1)

    Hi Drumbo:
    This isn't a direct answer, but I see your using legal style outline numbering. The whole purpose of that style is so there is no confusion as to where you are in the outline. Unlike the standard:
    I.
    A.
    1.

    style, where the previous levels aren't repeated, there should be no 2 lines that have the same number. Also, if you're still in the process of creating the document, switching to outline view & hiding the levels that you don't immediately need to see is often helpful. Lastly, if you have actually divided the document into sections, the status bar at the bottom should give you the section number that you're in.
    Hope this help,

  3. #3
    New Lounger
    Join Date
    Feb 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Headings and subheadings (Office XP - SP1)

    Phil,

    Thanks for your response. The main issue is that each heading 3 has the same set of heading 4 and 5 in it. (If that makes sense). For example
    1.1.1 Heading 3
    1.1.1.1 part 1
    1.1.1.2 part 2
    1.1.2 Heading 3
    1.1.2.1 part 1
    1.1.2.2 part 2

    Anyway it it sometimes hard to remember what each section is (the title) and I find I have to end up scrolling through masses of pages to remind myself where I am. I guess it is probably pure laziness, but if there is away around this! [img]/forums/images/smilies/smile.gif[/img]

    Again thanks for your response.

    Regards
    Drummond

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Headings and subheadings (Office XP - SP1)

    Here is a rough macro - you will have to remove the sharp edges yourself. Run it once when you have created all the headings. If the heading texts change later, select the entire document (Ctrl+A) and update fields (F9)

    Sub AppendHeading3To4()
    With Selection.Find
    .ClearFormatting
    .Style = ActiveDocument.Styles(wdStyleHeading4)
    .Text = ""
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    Do While .Execute = True
    Selection.EndKey Unit:=wdLine
    Selection.TypeText Text:=" "
    Selection.Font.Size = 8 ' change if you like
    Selection.TypeText Text:="("
    Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
    Text:="STYLEREF ""Heading 3"" ", PreserveFormatting:=True
    Selection.TypeText Text:=")"
    Selection.MoveRight Unit:=wdCharacter, Count:=1
    Loop
    End With
    End Sub

    Notes on the rough edges:
    - The macro will go into an infinite loop if the document ends with a paragraph in Heading 4 style.
    - The macro does not check whether the STYLEREF fields have been inserted before, so if you run it twice inadvertently, you'll end up with duplicates.

  5. #5
    New Lounger
    Join Date
    Feb 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Headings and subheadings (Office XP - SP1)

    HansV,

    That is brilliant. I am not much of a macro capable person, however I managed to get it to run and I think I have figured out parts of how it works (i.e. adjust stuff if I need). The only thing I cannot work out is that it seems to add the extra bits twice (this is on a clean doc - i.e have not run the macro before)
    for example I get

    4.1.13.7 Heading 4 (heading 3) (heading 3)

    If you can let me know why this happens I would be most grateful!

    Again my thanks for all the help

    Edit: Sorry for the extra question : but I was trying to figure out how to put the inserted header before the existing headers text.

    e.g. 4.1.13.7 (heading 3) Heading 4

    Edit 2: I have managed to put the heading like above using Selection.StartOf Unit:=wdLine instead of the endkey and it seems to work fine! (It took a while and some very strange looking changes to my document)

    I also managed to figure out why it was putting in the double entry and that was due to me starting the script in the middle of the document.

    Thanks again!

Posting Permissions

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