W2003: find cursor location in table coordinates (table/row/column

K

ker_01

I've been asked to extract data from an existing form that I didn't set up,
and the format is less than ideal. To minimize my cycles of testing, it would
be much easier to place my cursor in a sample document, and then debug.print
the cursor location as table coordinates so I can hardcode the 'cells' that I
need to extract. There are about 15 tables total, and I'll have to extract
content from most of them.

I played around with the range.parent object but couldn't figure out how to
return the table info.

I also googled, but no joy.

Any suggestions or snippets would be greatly appreciated.

Thanks,
Keith
 
G

Greg Maxey

Dim pTableNumber As String
pTableNumber = "The selection is in table: " & _
ActiveDocument.Range(0,
Selection.Tables(1).Range.End).Tables.Count
MsgBox pTableNumber & ". The selection covers " &
Selection.Cells.Count & " cells, from Cell(" & _
 
K

ker_01

That definitely gives me the table number, and now I realize why the source
form looks so 'wonky' - it has tables embedded in tables. So, When I'm in
"Table 3" and click in the upper area, I get cell (1,1). But when I click
into the first cell of the embedded table, I also get "Table 3 (1,1)".

Is there a preferred method for identifying embedded tables so that I can
treat each one independently? I have some cells in parent tables that appear
to have more than one child (embedded) table, even within just the one cell.

Thank you!
Keith
 
K

ker_01

I'm halfway there; I just had to find out that the object model uses "nested"
instead of "embedded" to describe these tables. So now I added:
lngNestLvl = Selection.Cells.NestingLevel

Which accurately gives me the /level/ of nesting, but does not give me the
table number of the nested table.

In other words, I create a 1-cell table, and within that cell I add two
different nested tables. I run my code in cell 1 of each nested table, and
they both tell me that I am in table 1 (overall parent table), nested at
level 2, and in cell 1,1 (which seems to refer to the child table, not the
parent table).

If there is more than one nested table in a single cell, how do I tell which
one I am in?

Thank you!
Keith
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top