Solved

Modify Table of Contents (TOC)

Posted on 2011-09-25
14
386 Views
Last Modified: 2012-05-12
I need some help with modifying my table of contents for >> Tables" and "Figures".

Please find attached two documents:
1. "Snapshots -- illustrating goal of modified template.doc" -- this includes the details as to what I need to accomplish

2. "TOC.doc" -- this template (shortened for testing purposes) serves as the framework for making the necessary changes.

As I didn't want to provide the full template, please provide the specific steps in the thread so that I can replicate them in my template.   If I can copy/paste the style or TOC [for Tables] and TOC [for Figures] w/o losing the format, please repost "TOC.doc".

Thanks,
EEH
Snapshots----illustrating-goal-o.doc
TOC.doc
0
Comment
Question by:ExpExchHelp
  • 7
  • 7
14 Comments
 
LVL 21

Accepted Solution

by:
EricFletcher earned 500 total points
ID: 36599036
The \a switch in the TOC field code will drop all of the "Table n. " part, and the \c switch includes it all -- but no switch is available to include just the number.

However, you can remove the non-numeric part with Find and Replace after the ToCs have been updated. I realize this is not as ideal as a fully-automatic solution, but you could set it up in a macro so it updates the fields and does the F&Rs.

In the Find and Replace dialog:
  Find what: (Table )([0-9]{1,2})(.)
  Options: Use Wildcards
  Replace with: \2\3

This finds all instances of Table space followed by one or two digits (use {1,3} if your table count may exceed 99) followed by a period. It replaces the found content with just the digits and period. Use the same approach for the Figures.

You shouldn't just remove "Table " in case the table titles include it.

When you update the ToC again, the "Update page numbers only" option will not rebuild the table, so you only need to repeat the F&R when you have to re-update the entire table.
0
 

Author Comment

by:ExpExchHelp
ID: 36599713
Eric:

Thanks for the feedback.   I'd prefer to first modify the field code scenario.

I looked at the field codes and tried adding the "\a" in different locations.   Once untoggling the field codes again -- followed by a full table update -- no changes occurred.

I presume I added the \a in the incorrect location.   Please see attached screenshot... could you please let me know what the modified field code should look like?

Thanks,
EEH


Tables-ToggleFieldCodes.JPG
0
 

Author Comment

by:ExpExchHelp
ID: 36599828
Eric:

Sorry... I may have misread your posting.   Apparently, there's no option to modify the TOC.

Ok, moving onto the macro recommendation...

I'm not too sure if I fully understand how to create this macro?    Would you be willing to post the actual code?    I need to make sure that it only replaces the "Table " (including additional space before the #) references within the TOC only.   [Same applies for the Figure TOC"]

Much appreciated!!

EEH
0
 
LVL 21

Expert Comment

by:EricFletcher
ID: 36600019
Include the \a switch within the TOC field code. The \c switch specifies the sequence to use; in your case, "Table" and "Figure" as the default ones used by inserting captions (although any sequence used in an SEQ field code could be used in the same way). This screen shot shows the generated ToC for your tables using your original TOC field code and a more minimal one with the \a switch. Results of two TOC field codes using different switches
Your TOC field code includes the \t switch to cause any instances of the Table style to be set as level 1. If a table caption were to be included in a different style for some reason, it would not appear in your ToC, whereas it will with mine as long as the "Table" sequence is used.

Refer to this Microsoft page for descriptions and examples of the various TOC field code switches.

Note: My screen shot shows the TOC field code results set with a grey background because I have that Word option turned on (File | Options, Advanced, Show document content, Field shading=Always). This is useful for seeing where content is generated versus typed -- and it only appears on the screen, not in print.  
0
 
LVL 21

Expert Comment

by:EricFletcher
ID: 36600117
We're overlapping our posts here I guess.

The Find and Replace suggestion is not a macro: use the settings I suggested within the F&R dialog to get it to do what you need. It makes use of the often-overlooked but very powerful wildcard options to do its magic.

If this was something you wanted to do frequently you could record a macro: select the TOC; click the Record Macro button; press F9 and choose to update entire table; Ctrl-H to bring up the Find and Replace dialog so you can fill in my parameters as noted above; click Replace All and do NOT continue looking in the rest of the document; then turn off the Record Macro button.

Unless you need to do it very frequently, I would suggest just using the F&R dialog as needed. You have ToCs for Tables and Figures, so you'd need two macros, and it would be essential to have the right one selected before invoking the applicable macro.
0
 

Author Comment

by:ExpExchHelp
ID: 36600139
Eric:

I just checked out your previous comment... it's going in the right direction.   I do need to include the # though.  Please see attached JPG for details.

EEH
How-TOC-should-look-like.JPG
0
 
LVL 21

Expert Comment

by:EricFletcher
ID: 36600326
Have you tried the Find and Replace method? My F&R method should achieve exactly the same as your deletion of "Table " the three times.

The \a switch removes all of the captioning (i.e. "Table 1. ", "Table 2. ", etc.) so won't do what you want.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:ExpExchHelp
ID: 36600362
Eric:

I'm trying to build the macro for the F&R... when recording the macro (in Office 2007), I can't seem to highlight the table nor do other activities.

Do you know what the macro code would look like?   If yes, I could create a dummy macro and then replace it w/ your code.

Thanks,
EEH
0
 

Author Comment

by:ExpExchHelp
ID: 36600414
Sorry for making this thread longer that it needs to be...

Ok, I tried the F&R as you suggested (w/o macro right now).

Once I enter the search criteria, it doesn't find any instances... did I misinterpret your search criteria?  See attached JPGs.

EEH
F-R.JPG
SearchResults.JPG
0
 
LVL 21

Expert Comment

by:EricFletcher
ID: 36600439
That's part of the reason I was hesitant to recommend a macro... It can be done, but requires more than what is possible with the record function.

However, if you select the table before you start recording the macro it should work properly. Of course, this means that the macro will only work if the table is selected first as well.

Did the F&R dialog do what you wanted?
0
 
LVL 21

Expert Comment

by:EricFletcher
ID: 36600482
Crossing again...

The F&R dialog looks right; did you have the table of Tables selected when you invoked it? And did you have the field code results showing (i.e. it won't work on the field code view). It worked fine for me with your content.
0
 

Author Comment

by:ExpExchHelp
ID: 36600483
Right now, using "(Table )([0-9]{1,2})(.)", I am also removing the numeric part + ". " from the F&R.

What's the search criteria for "Table " only... w/o selecting those in the body of the document?

EEH
0
 

Author Closing Comment

by:ExpExchHelp
ID: 36600571
Excellent solution... I've created a macro for the replace statement.   It does exactly what I needed for this solution.

Thanks, Eric!!!

EEH
0
 
LVL 21

Expert Comment

by:EricFletcher
ID: 36601504
Thanks EEH. Re the search criteria for just removing the "Table " part within the generated ToCs, use the Format Style option:

Find what: Table      [that is "Table " with the space]
Format Style=Table of Figures  (Your ToC for the tables was set with Table of Figures style)
Replace with: (empty)

This method will only alter the found items if they exist within the specified style -- and would be a viable alternative to using the wildcards. Although they appear more complicated, I tend to use wildcards because they can be more precise -- and only by using them can I keep myself current for howe they work!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

I'm writing to share my clumsy experience in using this elegant tool so you can avoid every stupid mistake I made. (I leave it to the authorities to decide if this deserves a place in the Knowledge archives.)  Now that I am on the other side of my l…
Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now