Special Find/Replace (Changing the Format Not the Content?)

  • Thread starter Faraz Ahmed Qureshi
  • Start date
F

Faraz Ahmed Qureshi

I have a long piece of text copied from a notepad with a structure as follows:

Sub Heading XY
TextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextText

Sub Heading AB
TextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextText

Sub Heading MN
TextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextText

....

Now in this text I want to BOLD the sub headings. With
Find: ^p^p
Replace:~~~
I have the article converted the above piece of text converted to:

Sub Heading XY
TextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextText~~~Sub Heading AB
TextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextText~~~Sub Heading MN
TextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextText

Now, how to convert ~~~<<Normal Format Subheading>>^p to ^p<<BOLDED Format
Subheading>>^p.

In simple language anyway to change only the format of a text piece like by
using a wildcard but keeping the text data same???
 
F

Faraz Ahmed Qureshi

After

Find: ^p^p
Replace:~BFaraz~

&

Find: ^p
Replace:~EFaraz~

Finally made this macro workout for the same!
Running the same a few times to convert all!

Sub Macro1()
For x = 1 To 2000
Selection.Find.ClearFormatting
With Selection.Find
.Text = "~BFaraz~*~EFaraz~"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
Selection.Font.Bold = True
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top