View Single Post
 
Old 07-05-2022, 10:24 AM
Shmuel G Shmuel G is offline Windows 10 Office 2019
Novice
 
Join Date: Jul 2022
Posts: 3
Shmuel G is on a distinguished road
Default

Quote:
Originally Posted by Shmuel G View Post
This technique destroys any character formatting within the selection, such as change of fonts. Is there a simple way to replace the text of the range with the new version, while preserving the original formatting?
It seems that replacing the .Text of each of the Characters in a range, one at a time, will preserve the formatting, but that requires the replacement string to be the same length as the original string.

If not for the trimming and replacement of double spaces, formatting could be preserved by replacing
Code:
.Text = StrTmp
with
Code:
  Dim i As Long
  For i = 1 To .Characters.Count
    .Characters(i).Text = Mid$(StrTmp, i, 1)
  Next
Reply With Quote