View Single Post
 
Old 01-04-2024, 08:36 AM
hss001 hss001 is offline Windows 10 Office 2021
Novice
 
Join Date: Dec 2023
Posts: 20
hss001 is on a distinguished road
Default

Thanks for your help with this.

I have something similar, but using the Find command on the Selection.
So if the Selection is modified the Find doesn't work correctly.

Code:
    m_oWordDoc.Bookmarks("\StartOfDoc").Select
    m_oWordApp.Selection.Find.ClearFormatting

    With m_oWordApp.Selection.Find
        .Text = sPhraseToFind
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = bMatchCase
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False

        Do While m_oWordApp.Selection.Find.Execute = True
                sSentenceToSearch = m_oWordApp.Selection.Sentences(1)
                ' Above is incorrect if the found text is the last row in a table
                ' Additional Code

            End If
        Loop
    End With
Reply With Quote