Consulting

Results 1 to 12 of 12

Thread: Count specific bold text

  1. #1

    Count specific bold text

    Hi, I need to count specific bold text. Please suggest. ms word vba

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    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.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Quote Originally Posted by macropod View Post
    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.

  4. #4
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    What specific bold text? Count what about the bold text - the number of words, characters, something else?
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  5. #5
    Quote Originally Posted by macropod View Post
    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

  6. #6
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    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
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  7. #7
    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".

  8. #8
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Try changing:
    .MatchWholeWord = False
    to:
    .MatchWholeWord = True

    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  9. #9
    Hi
    I tried but counting all. Please suggest

  10. #10
    Hi Paul, what is problem here? can u suggest

  11. #11
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    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>
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  12. #12
    Thanks! Paul Edstein

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •