+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Forum Guru zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    5,740

    Two row heading showed as one

    I have headings named in two rows (e.g.)

    Indiana Jones
    Raiders of the Lost Ark

    Indiana Jones
    and the Temple of Doom


    but when I insert table of contents I get:

    Indiana Jones........................................2
    Raiders of the Lost Ark............................2
    Indiana Jones .......................................15
    and the Temple of Doom..........................15

    and I want (automatic) index table like:

    Indiana Jones Raiders of the Lost Ark.......2
    Indiana Jones and the Temple of Doom.....15

    How can I do that?

    example.zip
    "Relax. What is mind? No matter. What is matter? Never mind!"

  2. #2
    Forum Contributor
    Join Date
    08-19-2006
    Posts
    116

    Re: Two row heading showed as one

    Hi,

    If i take your example:Indiana Jones........................................2, with the following code:
    Code:
    Sub Macro()
    Dim i
    For i = 1 To End
        Selection.MoveRight Unit:=wdWord, Count:=3, Extend:=wdExtend
        Selection.TypeText Text:=" "
        Selection.Delete Unit:=wdCharacter, Count:=1
        Selection.MoveDown Unit:=wdLine, Count:=1
    Next i
    End Sub
    you'll have
    Indiana Jones Raiders of the Lost Ark.......2
    Indiana Jones and the Temple of Doom.....15

    This code works with Word 2007 and you have to put the cursor after Indiana Jones before the macro.

    Bye Indy
    Last edited by shg; 07-15-2009 at 05:06 PM.

  3. #3
    Forum Moderator teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    2003 & 2010
    Posts
    10,042

    Re: Two row heading showed as one

    zbor,

    there's no need for macro code to achieve what you want. If you have a two-line title, make sure to break the line with Shift+Enter instead of just Enter. This will insert a soft line break, which in a table of contents will be ignored, so the title ends up in one line in the TOC.
    teylyn
    Microsoft MVP - Excel
    At Excelforum, you can say "Thank you!" by clicking the icon below the post.

    Avoid pie charts with more than two data points. Why? See here (pdf, 559 kb). The only acceptable pie chart is here.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0