I am trying to remove a carriage return from a text box with formatted text:
For i = ThisShape.TextFrame2.TextRange.Runs.Count To 1 Step -1
ThisText = ThisShape.TextFrame2.TextRange.Runs(i).Text
ThisText = Replace(ThisText, Chr(13), "")
ThisShape.TextFrame2.TextRange.Runs(i).Text = ThisText
Next i
For some odd reason, the text box remains with a carriage return. Any help would be appreciated.
David
The
CLEAN
function is rarely used, thus often forgotten.CLEAN
removes non printable characters (ASCII 0 through 31) from the given text. You can use it in VBA:...or as an Excel worksheet function:
Example:
...returns:
List all characters within string:
The procedure lists the characters and their codes found in the specified string:
Example Output:
More Information:
Office.com : CLEAN Function (Excel/VBA)
MSDN : WorksheetFunction.Clean Method (Interop)
ascii.cl : ASCII Codes Tables
MSDN : Chr & ChrW Functions (Interop)
MSDN : Asc & AscW Functions (Interop)
Wikpedia: ASCII
Wikpedia : Control (aka Non-Printable) Characters