Results 1 to 9 of 9
  1. #1
    Lounger
    Join Date
    Aug 2015
    Posts
    44
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Need macro for marking items for TOC in Word 2010

    Can someone help me figure out how to record a macro to mark items for the TOC in Word 2010? I know there's a way to do it but for the life of me I've not been able to figure it out and have been trying for over a week. I've read the links I was provided about recording macros but that didn't help me (frankly they were over my head a bit). Some of them had some examples of things to try and I tried following along and was able to do a few of them but even some of the things you were supposed to do in those samples I couldn't get it to do even when I did it exactly as they said. Not sure what I was doing wrong. Guess my hair is too blonde for it LOL.

    I'm needing to mark things for level 1 and 2 of the TOC. Here's the steps I did to record the macro for TOC1.
    1. Clicked on View tab> Record macro
    2. Gave it a name, filled out the description and then clicked on Keyboard and then clicked ALT+8 for shortcut key and clicked Close.
    3. (With the little cassette tape icon showing for my mouse cursor indicating it was recording) I typed the following keys: ALT+S+A then arrow keyed down to Level 1 and pressed enter.
    4. Then I used my mouse to go up and clicked on View tab>Stop recording.


    Then I pressed ALT+8 and NOTHING. I clicked on ALT+S+A to check to see if it had marked it but it didn't. I even tried highlighting the text to be marked first before recording the macro and then going through the same steps above with the same result. What am I doing wrong? Besides everything LOL.

    I know someone will say I'm supposed to use the VBA editor or whatever to record them but in order to do that I have to know how to tell it to do what I want.

    Thanks for any help you can provide!

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Is there a good reason for not using Word's Heading Styles for this?
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,048
    Thanks
    124
    Thanked 119 Times in 116 Posts
    Unless there is a reason, use the heading styles built into Word, as indicated by Paul. Here are some resources.
    Why use the built-in heading styles?
    How to create a table of contents.

    You can apply the Heading 1 style by clicking anywhere in a paragraph and pressing Ctrl+Alt+1. Do not select any text, just click in the paragraph.
    Similar shortcuts are built-in for Heading 2 and Heading 3.
    Last edited by Charles Kenyon; 2015-10-28 at 08:21.
    Charles Kyle Kenyon
    Madison, Wisconsin

  4. The Following User Says Thank You to Charles Kenyon For This Useful Post:

    naiveblueeyes (2015-10-28)

  5. #4
    Lounger
    Join Date
    Aug 2015
    Posts
    44
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Sorry for the delay in responding to you both. I'm not really sure if I can use just one style for level 2 TOC. The text that I am marking is authors' names and some of them have a hyperlink to their website. All of the level 2 text will be bold and centered so that at least will be consistent but the hyperlink is not so I'm not sure how that would affect a style? That was the issue I was running into with the macro. Level 1 won't be any problem. It's just bold and centered text. I know it tries to use Heading 1 but I can't stand the formatting on it and I know you're not really supposed to modify those. I could create a style but I'm note sure how it would work with the hyperlink issue?

  6. #5
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    There is nothing in what you've posted to suggest Word's built-in Heading Styles can't be used. Nor is there any reason you can't modify their formatting to suit your needs. Hyperlinks don't affect heading Styles, though applying a Heading Style to the paragraph containing a hyperlink may change the hyperlink's appearance slightly.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  7. The Following User Says Thank You to macropod For This Useful Post:

    naiveblueeyes (2015-10-28)

  8. #6
    Lounger
    Join Date
    Aug 2015
    Posts
    44
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thank you so much! That was so simple! I was definitely over-thinking it LOL. I did create a separate style to use for marking text for level 1 & 2 TOC so I'd have my formatting without having to modify one of the existing styles. I was able to figure that out with a simple Google search and found something on www.dummies.com which is right up my alley :-) Thanks again for your help!!

  9. #7
    Lounger
    Join Date
    Aug 2015
    Posts
    44
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Well, I've decided that I'm either cursed or Word has it out for me. Right after I created the first style I thought it was great that all was right with the world and I could go on my merry way so I thanked you and then went back and tried to create the second one and....Word crashed :-( When I restarted it my file was there in the recovered files thing and I thought all was well...WRONG! But I didn't know it. I kept working trying to get the second one created and got it but then they wouldn't mark the text for TOC. They would add the formatting for the style when I pressed the shortcut key but that was it. Then I tried using one of my other macros and nothing happened. So I thought maybe I was using the wrong shortcut key for it and when I went in to view my macros to see what macro name went with what text (to jog my memory for what keys to use) I saw that ALL of my macros are GONE!! See what I mean by being cursed?

  10. #8
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,048
    Thanks
    124
    Thanked 119 Times in 116 Posts
    I still haven't seen a reason to not use the built-in heading styles.

    The TOC only picks up paragraph-level styles. If you created a linked style and applied it to something less than a full paragraph, it will not pick up. I would suggest re-reading the pages I linked earlier.

    You can also use TC fields, but I don't recommend it.
    Last edited by Charles Kenyon; 2015-10-28 at 15:39.
    Charles Kyle Kenyon
    Madison, Wisconsin

  11. #9
    Lounger
    Join Date
    Aug 2015
    Posts
    44
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Ok, I finally broke down and modified Header 1 & 2 to use my formatting for levels 1 & 2 of TOC and now it's working. I also got all of my macros successfully re-recorded and miracle of miracles they actually work! I was definitely due some good luck since I just found out my dad has prostrate cancer. Thank you both for all of your help and for all the links you posted.

Tags for this Thread

Posting Permissions

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