From: ker_01 on
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

"Greg Maxey" wrote:

>
>
>
> 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(" & _
>
>
>
>
> ker_01 wrote:
> > I kept searching and found a partial answer here:
> > http://www.vbaexpress.com/kb/getarticle.php?kb_id=867
> > but that still doesn't get me the table number. Can anyone provide the
> > object model syntax to capture the table count as well?
> >
> > Thank you!
> > Keith
> >
> > "ker_01" wrote:
> >
> >>
> >> 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
>
>
> .
>
From: ker_01 on
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

"ker_01" wrote:

> 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
>
> "Greg Maxey" wrote:
>
> >
> >
> >
> > 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(" & _
> >
> >
> >
> >
> > ker_01 wrote:
> > > I kept searching and found a partial answer here:
> > > http://www.vbaexpress.com/kb/getarticle.php?kb_id=867
> > > but that still doesn't get me the table number. Can anyone provide the
> > > object model syntax to capture the table count as well?
> > >
> > > Thank you!
> > > Keith
> > >
> > > "ker_01" wrote:
> > >
> > >>
> > >> 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
> >
> >
> > .
> >