Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 404
  • Last Modified:

Modify Table of Contents (TOC)

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
ExpExchHelp
Asked:
ExpExchHelp
  • 7
  • 7
1 Solution
 
Eric FletcherCommented:
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
 
ExpExchHelpAuthor Commented:
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
 
ExpExchHelpAuthor Commented:
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
[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

 
Eric FletcherCommented:
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
 
Eric FletcherCommented:
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
 
ExpExchHelpAuthor Commented:
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
 
Eric FletcherCommented:
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
 
ExpExchHelpAuthor Commented:
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
 
ExpExchHelpAuthor Commented:
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
 
Eric FletcherCommented:
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
 
Eric FletcherCommented:
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
 
ExpExchHelpAuthor Commented:
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
 
ExpExchHelpAuthor Commented:
Excellent solution... I've created a macro for the replace statement.   It does exactly what I needed for this solution.

Thanks, Eric!!!

EEH
0
 
Eric FletcherCommented:
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 7
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now