Search code examples
vbams-wordword-field

display all field codes (instead of results)


I need to display the fields code and use:

Document.Content.Fields.ToggleShowCodes

I have fields, some are in text boxes and need showing all of them.

But the above toggles - and I need more control. If the codes are showing, performs display fields results.

So I need if fields code are showing, do nothing, else show all fields code, even if they're are in the text boxes.


Solution

  • You can use the View.ShowFieldCodes property which takes/accepts a Boolean:

    ActiveWindow.View.ShowFieldCodes = True
    

    It doesn't matter whether any or no field codes are currently displayed: ALL will be displayed.