test for active table

S

skrimpy

I have been provided this code from some wonderful collegues on this
site.(Word 2000 and XP)

Set myrange = Selection.Bookmarks("\Page").Range
myrange.End = myrange.End - 2
myrange.Collapse wdCollapseEnd
myrange.Cells(1).Range.Select
Selection.HomeKey Unit:=wdRow

It works great for selecting the last row on a given page(table is most
of the document and stretches from page to page).
As Im looping through my document and using the bottom left corner as a
reference point to make changes to my document this line fails when the
next jump is off of the table. ("Run-Time error '5941' The requested
member of the collection does not exist")

myrange.Collapse wdCollapseEnd

I need my loop to stop if this code jumps off of the table, or this
code(Selection.MoveDown Unit:=wdLine, Count:=1) jumps off the table.
Does anyone know if it is more correct to use an error handling
statement for this, or is there a better way to break the loop?
Thanks!
Dan
 
D

Doug Robbins - Word MVP

Use Selection.Information(wdWithinTable) to check if the selection in a
table.

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

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