CleanString Method Example

This example removes nonprinting characters from the selected text and inserts the result into a new document.

cleanUp = Application.CleanString(Selection.Text)
Set myDoc = Documents.Add
myDoc.Content.InsertAfter cleanUp

This example removes nonprinting characters from the selected field code and then displays the result.

ActiveDocument.ActiveWindow.View.ShowFieldCodes = True
ActiveDocument.Fields(1).Select
MsgBox Application.CleanString(Selection.Text)