Tuesday, October 30, 2012

Find content In Word Document

Public Function fnFindInWordDocument(strFilePath, strStringToFind)
Set oWord = CreateObject("Word.Application")
Set oDoc = oWord.Documents.Open(strFilePath)
isFound =False
For n = 1 To oDoc.Paragraphs.Count
               startRange = oDoc.Paragraphs(n).Range.Start
               endRange = oDoc.Paragraphs(n).Range.End
               Set tRange = oDoc.Range(startRange, endRange)
               tRange.Find.Text = strStringToFind
               tRange.Find.Execute
               If tRange.Find.Found Then
                   isFound =True
                    Exit For
               End If
Next
If isFound =True Then
    fnFindInWordDocument =True
Else
    fnFindInWordDocument =False
End If
oDoc.Close
oWord.Quit
Set oDoc = Nothing
Set oWord = Nothing
End Function

4 comments:

  1. Nice post! ui courses online
    equips designers with both creative and technical skills.

    ReplyDelete
  2. A full stack Python developer course focuses on backend skills. It includes real-world projects. Practical learning enhances experience. Structured guidance improves clarity. This full stack python developer course supports success. It is dependable.

    ReplyDelete
  3. An android app development course focuses on building functional Android apps. It combines theory with practical coding. This android app development course supports career growth. It is dependable.

    ReplyDelete
  4. Excellent insights! Well-designed database modeling course
    ensure consistency, accuracy, and long-term system growth.

    ReplyDelete