Search multiple word documents for a keyword

I’m trying to create a sequence which checks the content of multiple Word documents in a particular directory for the word ‘Private’. This is how my sequence is constructed at the moment:

  1. Assign activity: Documents = Directory.GetFiles(“C:\Development\UIPath\Word files”)
  2. For each activity: item in Documents
  3. Body: Word application scope activity: Documents.ToString
  4. Do: Read text activity: DocumentContents
  5. If condition: DocumentContents.ToString.Contains(“private”)
  6. Then: Log message activity: Documents.ToString + " includes the word Private"
  7. Else: Log message activity: Documents.ToString + " does not include the word private"

When I look at the output, all 5 documents show ‘does not include the word private’, even though two of the documents do have the word private. I’m just mucking around but don’t know why this isn’t working, any help appreciated!

The word case is correct? Lowercase?
Share a sample line from the doc with the word.

Hi @dhymeri10,

Your sequence steps are good. And you are right. But I don’t know the content length of the word document.
But I have attached the project with sample document for you by using the find and replace activity.

File (37.3 KB)


There are 5 word documents with 5 key values but i need to check a condition if the type is resistor then I need to capture only the values excluding resistor … I have done this manually 5 times for a file using screen scrapping But I don’t want to do screen scrapping how to do it @balupad14