Hi,

I'm wondering why the Table object does not have an Index property?
This object belongs to a collection (Tables), so it should have one.

What is the reason this object, just like Document or Paragraph does
not have that property?

Thanks in advance.

Raph

Re: Why doesn't the Table object have an Index property by Peter

Peter
Thu Aug 26 09:29:56 CDT 2004

Hi Raphael Goubet

Strangely tables and numerous other objects don't have an index property. However, there
is a standard word around to this problem:

Public Function TableIndex() As Long
Dim rngToTable As Word.Range

' No table in selection then nothing to return
If Selection.Tables.Count > 0 Then

' Set range to first table of selection
Set rngToTable = Selection.Tables(1).Range
rngToTable.MoveStart wdStory, -1

' Return the tables effective document index
TableIndex = rngToTable.Tables.Count
End If
End Function

HTH + Cheers - Peter


rgoubet@yahoo.fr (Raphael Goubet), said:

>Hi,
>
>I'm wondering why the Table object does not have an Index property?
>This object belongs to a collection (Tables), so it should have one.
>
>What is the reason this object, just like Document or Paragraph does
>not have that property?
>
>Thanks in advance.
>
>Raph


Re: Why doesn't the Table object have an Index property by Jezebel

Jezebel
Thu Aug 26 17:10:38 CDT 2004

It's a result of the standard way Collections are managed in VB and VBA.
Each member of a collection has an Index and optionally a Key; however these
are properties of the *Collection* not of the item. The index is determined
by the item's current position in the collection, and changes if preceding
items are added or removed -- as you see happening with most of Word's
collections, like Tables(), Paragraphs(), Words().

The Index is not a property of the item itself because the item has no
control over its storage. You can have multiple collections containing the
same type of object; and one object can be a member of more than one
collection. In the case of a Table, if it had an Index property how would
you know if the index referred to its position within

ActiveDocument.Tables
ActiveDocument.Bookmark("MyBookMark").Tables
ActiveDocument.Application.Selection.Tables
Activedocument.Sections(2).Range.Tables

etc? The same table might be a member of all of these, with a different
index in each case.



"Raphael Goubet" <rgoubet@yahoo.fr> wrote in message
news:da59d264.0408260512.f40bf9a@posting.google.com...
> Hi,
>
> I'm wondering why the Table object does not have an Index property?
> This object belongs to a collection (Tables), so it should have one.
>
> What is the reason this object, just like Document or Paragraph does
> not have that property?
>
> Thanks in advance.
>
> Raph



Re: Why doesn't the Table object have an Index property by rgoubet

rgoubet
Fri Aug 27 00:55:36 CDT 2004

OK, I get it.

Thanks for this very clear explanation.

Raphael

Re: Why doesn't the Table object have an Index property by rgoubet

rgoubet
Fri Aug 27 00:56:54 CDT 2004

That's a good trick to know, thanks.

Although I don't have a clue how it works! :-)

Raphael

Peter Hewett <nospam@xtra.co.nz> wrote in message news:<gasri0dkgorj95hjgo32pbjvpehhhdqigr@4ax.com>...
> Hi Raphael Goubet
>
> Strangely tables and numerous other objects don't have an index property. However, there
> is a standard word around to this problem: