Find last table in Word Document

uiautomation
word

#1

I am working on formatting of tables present in the word document.

For formatting, I have used CTRL+G and selected “Table” under Goto. “Next” button is used for going to next table.

image

I have included flow decision to format all the tables. But once the last table reaches, it does not throw any error. So it is impossible to end the workflow. The last table gets formatted infinite times.

Please help me in finding the last table in word Document. Even count of tables also helps.


#2

I’m having exactly the same issue. Does anyone know how to solve this?


#3

Hi @jcab,

I have found one solution for this.
Please find the attached workflow, let me know if you have any doubts on this.

Regards,
Saranya K RFinding_LastTable.zip (13.7 KB)


Go to Last table in Word document
#4

@SaranyaKishore, thanks for your reply.

Thank you very much for the sample.
I tried to run it on my PC, but it unfortunately does not work.

It seems a bit complex, and the algorithm is completely different from the one I’m using, which is the one we are talking about in this topic: basically using the shortcut CTRL+G to travel through the tables. And there is no way to detect the last table: basically there is no way to stop CTRL+G and the last table is iterated endlessly.


#5

Hi,

Yes, there is no way to stop Ctrl+G. It keeps on running.

Operations need to be included in the loop once the last table reaches it will come out of the loop.

Inside the loop:

  1. First, copy the table header and save it in a variable say SELECTED_PREV_TEXT.

  2. Then if you need to perform some operation, you can include here.

  3. Again copy the table header, save it as SELECTED_NEW_TEXT.

For tables other than last table, two variables doesn’t match.

For last table, variables have same value. So it comes out of loop.

One drawback in this algorithm is for last table Find Next in Ctrl +G is performed twice. So all the operations inside the loop also will be performed twice.

Write line can be used to check variable values which will be more helpful in understanding.

Thanks,

Saranya K R


#6

Hi @jcab,

May I know what error do you face while executing? Because it works fine for me.