PDA

View Full Version : [SOLVED:] Count specific bold text



Vijayrathina
01-02-2019, 12:58 PM
Hi, I need to count specific bold text. Please suggest. ms word vba

macropod
01-02-2019, 02:04 PM
You need to be more specific.

Kindly also don't resurrect ancient threads - the one you posted in was last active well over a decade ago.

Vijayrathina
01-02-2019, 10:46 PM
You need to be more specific.

Kindly also don't resurrect ancient threads - the one you posted in was last active well over a decade ago.

I have document files. I have to count specific bold text in document.

macropod
01-02-2019, 10:57 PM
What specific bold text? Count what about the bold text - the number of words, characters, something else?

Vijayrathina
01-02-2019, 11:29 PM
What specific bold text? Count what about the bold text - the number of words, characters, something else?

Hi, I will give input text. If I give input "Hello text", how money times coming "Hello text" in bold. Please help

macropod
01-02-2019, 11:32 PM
For that you might use a macro like:

Sub Demo()
Application.ScreenUpdating = False
Dim i As Long
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = InputBox("What is the Text to Find")
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
.Font.Bold = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute
End With
Do While .Find.Found
i = i + 1
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
Application.ScreenUpdating = True
MsgBox i & " instances found."
End Sub

Vijayrathina
01-02-2019, 11:48 PM
Thank you so much for your help. "Figure 10-1" this text need to be count but "Figure 10-10", "Figure 10-10A" should be excluded. please advise. I need this count only "Figure 10-1".

macropod
01-02-2019, 11:54 PM
Try changing:

.MatchWholeWord = False
to:

.MatchWholeWord = True

Vijayrathina
01-03-2019, 12:07 AM
Hi
I tried but counting all. Please suggest

Vijayrathina
01-03-2019, 12:58 AM
Hi Paul, what is problem here? can u suggest

macropod
01-03-2019, 05:00 AM
In that case, you could replace all of:


.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
with:

.MatchWildcards = True
and input your Find expression as:

Figure 10\-1>

Vijayrathina
01-03-2019, 07:45 AM
Thanks! Paul Edstein