How to retrieve values from a word document?

Hello everyone,

I am a newbie in Uipath, and I appreciate your hints, advice or even solutions.
I have a word document (.docx) contains information about a new Employee. It is two pages long
with several fields:
First name: John
Last name: Doe
Social Security Number: 123145678
Address: Abcdef
xxx: abcd
yyy: efgh

So 2 questions:

  1. How can I skip the fields “First name”, “Last name”, other fields and linebreaks?
  2. How can I save their corresponding values “John”, “Doe”, etc. into string variables?

I need thesse variables so I can type them into our navision accounting system.
Thank you.

1 Like

Hi @Pirouz,
You have to first install the package from Package manger to UiPath Studio.

UiPath.Word.Activities, where you have all the activities to do any kind of work in the Word.

For splitting by New Line:
YourText.Split(Environment.NewLine.ToArray,StringSplitOptions.RemoveEmptyEntries)

Read the Word Document and store it in a variable WordOutput
To get John:
Jon=WordOutput.Split(Environment.NewLine.ToArray,StringSplitOptions.RemoveEmptyEntries)
John=WordOutput.Split(“First name”)
John=John(1).Split(“Last name”)
John=John(0).trim

1 Like

@Pirouz,

First Take Word Application scope activity - to read word document
Read text activity - to store word document output
image

Try Like this:

FirstName: wordText.Substring(wordText.IndexOf("First name: ")+"First name: ".Length).Split(Environment.NewLine.ToCharArray)(0)

2 Likes

Hi Baisilgee,
Thanks for your reply
I have added word automation and now trying to resolve the issue. Thanks

1 Like

Ok @Pirouz, then close it by clicking the solution. Keep developing robos’…

Hi @lakshman and @Rahul_Pasupuleti

My problem was when I converted word to text, I got so many unicode characters in the text document. There were several line breaks between fields and values. I had to make a parser so I could have my desire text format. After that, I followed your instructions and everything worked out well. Thank you both.

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.