Replace First Character

I have a document in which I wish to replace the first character on all lines at once with a new character. Does someone know how I can accomplish that? Do note that Excel is not the answer, as the document contains 11,881,376 lines on which the first character must be replaced.

If you click on the Show\Hide button (¶), does each line terminate with a ¶?

If so, you could use:

Dim i As Long
With ActiveDocument
    For i = 1 To .Paragraphs.count
        With .Paragraphs(i).Range
        .Text = "H" & Mid(.Text, 2)
        End With
    Next i
End With

replace the "H" with the new character that you want as the first in each line.

Hope this helps,
Doug Robbins - MVP Office Apps & Services (Word)
dougrobbinsmvp@gmail.com
It's time to replace ‘Diversity, Equity & Inclusion’ with ‘Excellence, Opportunity & Civility’ - V Ramaswamy

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Thank you for the reply, Doug. I did get the document finished, but it is too large. The document is composed of all 6-tile (6- to 12-letter, as the Q is always coupled with the U) combinations for a word game. The file is approximately 2.37 gibi (or 2.54 giga) bytes in size. Windows registers it as being 2.36 gigabytes in size, which is incorrect. The units don't match the mathematics used. The numeric value clearly reflects use of the binary system. But, the units reflect the decimal system.
I love Daisy (デイジー)!

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

I am not really sure what you are saying as far as your original question is concerned.
Hope this helps,
Doug Robbins - MVP Office Apps & Services (Word)
dougrobbinsmvp@gmail.com
It's time to replace ‘Diversity, Equity & Inclusion’ with ‘Excellence, Opportunity & Civility’ - V Ramaswamy

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated December 15, 2023 Views 320 Applies to: