Read multiple word document in folder

loop
file

#1

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,


#2

try this in if condition

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


#3

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


#4

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


#5

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?


#6

Probably lower case? “dutch”?


#7

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


#8

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


#9

Like this?


#10

I want to see the output.


#11

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.


#12

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


#13

Like this?


#14

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

image


#15

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.


#16

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.

How to read data from word document?
#17

Perfect! It works. Thanks.