Accessing tables not by index

Sep 29, 2014 at 8:07 AM
Hi,

I am experimenting with this project (which looks promising) and I was wondering whether it is possible to access/reference a table with other mechanism than plane index (e.g. not myDoc.Tables[0]).

My issue is that I have a complex template with many tables. The number of tables may change (I currently read the number of tables from external configuration). I want to be able to easily access tables (by tag or name for example).

Alternatively, is there a way to access table before/after some marker (e.g. bookmark, predefined string) or something like that?
Sep 30, 2014 at 9:11 AM
Perhaps you could use the TableCaption and TableDescription? It's the Alternate Title and Alternate Description of a table, available from Word 2010+ (info).
You can simply access (or set) those properties by using Table.TableCaption and Table.TableDescription.
Sep 30, 2014 at 9:19 AM
That's a direction I can explore. To clarify the question, I am preparing a template so I would like before hand to put some "marker" on the table so that when accessing the code, I can easily access the table.

I will try and see if these feature helps.

Thanks!
Sep 30, 2014 at 9:27 AM
I am using the DocX lib from Nuget. I don't see these properties... Do I need to compile source to have them?
Sep 30, 2014 at 1:10 PM
The properties are not available in DocX v1.0.0.13, I think that's what you're using?
If you use the source code from CodePlex instead, the properties will be available.