View Full Version : Searching sections
I have a document with several sections. In one section is a particular table that I reference with some Macros. Becuase others routinely edit the base document and could possible add tables above or below the table in question, I am running into some trouble. What I want to do is isolate this table in it's own section, and then search only that section for the correct table. The Tables collection ignores sections so I am not sure how to identify the first table in a given section.
Any Ideas?
fumei
10-10-2008, 02:40 PM
To extend that thought, you can make a table object of that table - after you bookmark it as macropod suggests. Now it does not matter if you put tables before it, or move the table itself, or whatever. Assuming the same name as macropod...Dim oTable As Table
Set oTable = ActiveDocument.Bookmarks("myTbl").Range.Tables(1)
With oTable
.Cell(1, 2).Range.Text = "Hello"
.Cell(2, 2).Range.Text = "Goodbye"
End With
The advantage of this is that you can access all the properties and methods of THAT table. If you declare oTable as a global (Public) variable, and Set it, you can use it in as many Sub routines as you like. It will no difference what Section it is in.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.