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

So my codes below - highlighting where I want to retrieve the sentence. If I modify the selection the code doesn't function 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