Read multiple word document in folder

Hi,

I am trying to read multiple word documents around 7 and would like to check if they contain the word “Dutch” within the documents. Can someone help?

Kind regards,

try this in if condition

Path.GetFileNameWithoutExtension(item).Contains("Dutch")

It didn’t work. I got error message shown in pic! Can you help?

Change your item type to String in foreach OR just add ToString at the end in if condition.

The IF condition looks like Path.GetFileNameWithoutExtension(item.ToString).contains("Dutch")

But when I run the process all 8 documents within the folder bring the message box “NO” but I know 5 documents contain the word “Dutch”. Do you know why it isn’t working?

Probably lower case? “dutch”?

No it didn’t work. I have tried different words with upper and lower case. It just doesn’t seem to read the document.

Can you write line the item.ToString and share the screenshot?

Like this?

I want to see the output.

When I run the process, I have to choose the folder. When I select the folder I want. It then gives me a message box stating “NO” then I click “ok” on the message box 8 times as I have 8 word documents in the folder and that’s it.

Please upload a screenshot where the Output pane is visible (bottom left corner) and shows the result of item.ToString.

1 Like

Like this?

Correct. What keyword are you expecting to be in the file name in this case?

image

My process should read all 8 documents in the folder and check whether the word “Dutch” in contained within the documents if so, I will carry on with the process. Hope that makes sense.

Understood, you want “Dutch” word inside the document.

  1. inside foreach add “Word Application Scope” and pass item.ToString (word path) to it.
  2. Add “Read Text” activity and create an output variable for it (say wordText)
  3. Now out side “Word Application Scope” and inside “Foreach” add your if condition and pass if wordText.Contains(“Dutch”) and do your rest of the logic.
4 Likes

Perfect! It works. Thanks.