How to show only specific formatting marks/fields? (Such as TC fields only)

KSteele 71 Reputation points
2022-09-16T19:39:33.81+00:00

I can show all formatting marks using the following:

ThisDocument.ActiveWindow.View.ShowAll = True

The result is the same as using the "Show/Hide" button built into the GUI (it also reveals line breaks, whitespace characters, tabs, etc)

Is there a way to only show specific fields, such as TC fields?

Thank you

Developer technologies Visual Basic for Applications
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. John Korchok 6,126 Reputation points
    2022-09-16T21:06:01.293+00:00

    Formatting marks are different from field codes. You can show all field codes with Alt + F9. Select a field and press Shift + F9 to view the field code for that field.

    To display the field codes for just one type of field, you would have to write a macro to loop through all fields, check the field type and display it if it's the correct kind..

    0 comments No comments

  2. KSteele 71 Reputation points
    2022-09-19T14:25:55.327+00:00

    Thanks JohnKorchok,

    I'm not trying to turn on field codes for one type of field, I'm trying to only display a particular type of field.

    In this case, I only want to show TC fields. (Table of Contents entries)

    If I used ThisDocument.ActiveWindow.View.ShowFieldCodes, this was also showing the code in REF fields as well which is not what I wanted.

    I found that using the following achieves what I'm trying to do (for someone else who might find this post):

    ThisDocument.ActiveWindow.View.ShowHiddenText = True

    Technically, this might turn on other things as well, but in my case, it's only showing TC fields. I imagine if you had other fields which are classified as "hiddenText" they would also show, in my case, it's only the TC fields.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.