If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Determine Table Index Number in a Table Collection
Simple problem I would think. In a document with multiple tables, how do I determine the index number of the table in which the cursor is located. I want to write this code
ActiveDocument.Tables(???) How do I know if my current location is Tables(1), Tables(2) or Tables(3) Thank you! Andrew |
#2
|
|||
|
|||
Determine Table Index Number in a Table Collection
Hi Andrew
See http://word.mvps.org/FAQs/MacrosVBA/...exNoOfPara.htm. Pay special attention to the first part, which explains that you usually don't need to know the absolute index of anything within the document. Something it doesn't say is that if you frequently refer to objects by their absolute index, your macro is likely to run extremely slowly in large documents. The reason is that every time you say something like ActiveDocument.Tables(n), VBA starts with .Tables(1) and counts tables up to n. If n is 100 or so, you'll bring the machine to its figurative knees -- and it's totally unnecessary! Andrew wrote: Simple problem I would think. In a document with multiple tables, how do I determine the index number of the table in which the cursor is located. I want to write this code ActiveDocument.Tables(???) How do I know if my current location is Tables(1), Tables(2) or Tables(3) Thank you! Andrew -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://www.mvps.org/word |
#3
|
|||
|
|||
Determine Table Index Number in a Table Collection
Thanks!!!
|
Thread Tools | |
Display Modes | |
|
|