Copy / Scraping tables in Word to Excel

Dear Experts,

I have an issue to scrap data from few tables (table having the same title, e.g. Management Action Plan / MAP) which spread across few pages in the report (Word document). There are also other tables in the report but I am only interested with data under MAP tables.

I have tried to use one method which I could find in the forum, e.g.
In the Word report -> Ctrl+H -> insert MAP -> Data Scraping the table.
But this will only scrap the first MAP table. It will not scrap the subsequent MAP table. Something to do with the idx table I guess.

Can anyone give me your advice so I can scrap all data in MAP tables in the report?

Thank you.

WordActivity in Uipath lacks function, so I simply wrote VBS. Call the following VBS with Uipath Invoke Vbscript.
I attached VBS and some screenshot.
Please write a reply if you need help.

image

Before Copy.

After Vbs, Paste(Ctrl +v)

Wordapplication_Copytable.zip (361 Bytes)

P.S.

Because Excel, Word, and Outlook are ComObject based, they can be controlled in any MS based language. (Powershells are also possible.) So, if you don’t know how to program in Uipath, you may be better off simply writing it. I will attach the relevant MSDN document.

https://docs.microsoft.com/en-us/office/vba/api/word.range.copy

2 Likes

Thank you Jihun for your feedback.

I am looking at your VBA script, it looks to me, first we need to know the idx of MAP tables in the Word doc (which could be idx = 4, 7,10 and 13 - just for example & of course I know how to find the idx tables), then we put those idx into the script where the script will be eventually run using Invoke VBScript of UiPath, am I right?

If YES, is there anyway for me to automate the idx so UiPath will only pick the idx of MAP that I am interested with?

Just to give you an idea about the MAP / Management Action Plan tables that I want to scrap which can spread into Point 1 & 2.

That’s right what you thought.
In general, unique qualifiers such as Cls (Classname) are used to distinguish elements.

However, there is no unique qualifier for the table. The only way to distinguish a table is by index and internal content (even two tables, Actionplan have the same content).

So you will have to make a strategy.

Since the contents of the table can be known (by writing VBS or copying it to distinguish it from the contents of Clibboad), all the tables are found through a loop, but the table after ‘Business Data Monitoring Control Category Table’ is the first action table. The next action table is recognized as the second action table.

If you want to differentiate between tables of the same type, you will need to devise a strategy to differentiate the tables as above (probably very difficult).

1 Like

Thank you very much for your feedback Jihun. Much appreciated :pray:

1 Like