Find Bold letter and add ** Before and after each bold letter of entire paragraph in Word

Nayasoch

Board Regular
Joined
Sep 9, 2016
Messages
73
Hello guys I need help with Ms word, where I have entire paragraph....I am looking for any vba code to add ** before and after each bold letter...so far I have

Rich (BB code):
Sum AsteriskText()

Dim keepSearch As Boolean

keepSearch = False

Selection.Tables(1).Columns(3).Select


Do
Selection.Find.ClearFormatting
Selection.Find.Font.Bold = True
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False


End With
Selection.Find.Execute


If Selection.Find.Found Then
keepSearch = True
Else
keepSearch = False
End If

With Selection
.InsertBefore "**"

End With


Loop While keepSearch


End Sub

It keeps on adding asterik....only on first bold letter and looping withitself....dosen't move to next one ( keeps repeating itself) and doesn't add ** after bold letter only before... Any help would be much appreciated.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Nayasoch, could you provide a short clip here of what your original copy might look like, and then the result you want (even a sentence)? That would help.
 
Upvote 0
Thank you for your interest ErikTyler.....I have an one or two paragraph on Microsoft word which contain some bold letters.......I want to put two asterik before and after of each bold letter.

Sample of Original copy

[FONT=&quot]Well, we’ve got some great news:A lot of incredible short stories are actually available online, and you can read them for free right now. It’s the perfect way to spend a lunch break, the moments while dinner is in the oven, or your last few minutes before bedtime. Without further ado, here’s our list of great short stories you can read for free right now. The list features a blend of works from contemporary authors, as well as short stories from your favorite classic authors.

Output should be like....
[/FONT]
[FONT=&quot]Well, we’ve got some great [/FONT][FONT=&quot]**[/FONT][FONT=&quot]news[/FONT][FONT=&quot]**[/FONT][FONT=&quot]:A lot of incredible short [/FONT][FONT=&quot]**[/FONT][FONT=&quot]stories[/FONT][FONT=&quot]**[/FONT][FONT=&quot] are actually [/FONT][FONT=&quot]**[/FONT][FONT=&quot]available[/FONT][FONT=&quot]**[/FONT][FONT=&quot] online, and you can read them for [/FONT][FONT=&quot]**[/FONT][FONT=&quot]free[/FONT][FONT=&quot]**[/FONT][FONT=&quot] right now. It’s the perfect way to spend a lunch break, the moments while [/FONT][FONT=&quot]**[/FONT][FONT=&quot]dinner[/FONT][FONT=&quot]**[/FONT][FONT=&quot] is in the oven, or [/FONT][FONT=&quot]**[/FONT][FONT=&quot]your[/FONT][FONT=&quot]**[/FONT][FONT=&quot] last few minutes before bedtime. [/FONT][FONT=&quot]**[/FONT][FONT=&quot]Without[/FONT][FONT=&quot]**[/FONT][FONT=&quot] further ado, here’s our list of [/FONT][FONT=&quot]**[/FONT][FONT=&quot]great[/FONT][FONT=&quot]**[/FONT][FONT=&quot] short stories you can read for free right now. The list features a [/FONT][FONT=&quot]**[/FONT][FONT=&quot]blend[/FONT][FONT=&quot]**[/FONT][FONT=&quot] of works from [/FONT][FONT=&quot]**[/FONT][FONT=&quot]contemporary[/FONT][FONT=&quot]**[/FONT][FONT=&quot] authors, as well as [/FONT][FONT=&quot]**[/FONT][FONT=&quot]short[/FONT][FONT=&quot]**[/FONT][FONT=&quot] stories from [/FONT][FONT=&quot]**[/FONT][FONT=&quot]your[/FONT][FONT=&quot]**[/FONT][FONT=&quot] favorite classic [/FONT][FONT=&quot]**[/FONT][FONT=&quot]authors**.

i.e two stars before and after each bold letter. I have thousand of such paragraph and we'll take longer time..if I had to do manually.so any help would be much much appreciated.[/FONT]
 
Upvote 0
Hello guys I need help with Ms word, where I have entire paragraph....I am looking for any vba code to add ** before and after each bold letter...so far I have
Hi, Nayasoch
Try this:
Code:
Sub MacroBold()
Selection.HomeKey unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Font.Bold = True
    With Selection.Find
        .Text = ""
        .Replacement.Text = "**^&**"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub
 
Upvote 0
I have an one or two paragraph on Microsoft word which contain some bold letters.......I want to put two asterik before and after of each bold letter.
I don't program in Word so I won't be able to help you with it, but given that it is a true word processor, I would think its macro capabilities must have methods available to locate bold text and be able to add asterisks on either side of such text. I think you would be better served asking your question in a Word forum where the experts there would more than likely be able to give you code to do what you want.
 
Upvote 0
@Nayasoch, you can do this with a fairly simple Find/Replace in Word.


1. Open the Replace dialog (Ctrl+H).

2. Expand to full options by clicking the [More >>] button at the bottom if it's not already expanded.

3. Click in the Find what: field so that the cursor appears there, but do not type anything.

4. Click the [Format...] button at the bottom of the expanded window. Choose Font from the list. A Font dialog box will appear. Under Font Style: select Bold. Click "OK" at the bottom to close that window.

5. Click in the Replace with: field so that the cursor appears there. Type the following:

**^&**

The ^& is Word's code meaning "whatever was here."

6. Click the [Format...] button at the bottom of the expanded window. Choose Font from the list. A Font dialog box will appear. Under Font Style: select Bold. Click "OK" at the bottom to close that window.

7. Click the [Replace All] button.

This looks like a lot, but the whole process takes about 60 seconds.
 
Upvote 0
We see that you had also Cross-Posted the question here: https://www.excelforum.com/word-pro...fore-and-after-of-bold-letter-in-ms-word.html

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule #13 here along with the explanation:
Forum Rules). This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.

Thanks
 
Upvote 0

Forum statistics

Threads
1,214,838
Messages
6,121,885
Members
449,057
Latest member
Moo4247

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top