Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2006

Tip: Looking for answers? Try searching our database.

Paragraph Number and Text accessed from a Table?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Joe HM - 13 Oct 2006 21:54 GMT
Hello -

I have a loop that steps through all tables of a document ...

For Each lTable In ActiveDocument.Tables
 ...
Next lTable

How can I determine the Paragraph Number and Paragraph Text that
contains the table?

Here is an example ...

3.1 Blah 1
Text ...
Table 1
More Text  ...

3.2 Blah 2
Text ...
Table 2
More Text  ...

I need to loop through all tables and determine under hich heading they
are - i.e. the heading immediately above the table (e.g. "3.1" and
"Blah 1" when lTable is Table 1).

Is there an easy way to do that?

Thanks!
Joe
Stefan Blom - 16 Oct 2006 10:15 GMT
If you are trying to reference the current Heading 2 paragraph, you
can use a STYLEREF field: { STYLEREF 2 \s }. Do the following to
insert it: Press Ctrl+F9; Word adds the field delimiters, {}. Type the
code as shown. Press F9 to update the field.

Note that you can have Word include a particular heading level in your
table captions. Just choose Insert | Reference | Caption. In the
Caption dialog box, choose "Table" for "Label." Click the Numbering
button. Enable the "Include chapter number" option and choose the
desired numbering level. Click OK twice.

Signature

Stefan Blom
Microsoft Word MVP

> Hello -
>
[quoted text clipped - 27 lines]
> Thanks!
> Joe
Joe HM - 17 Oct 2006 13:10 GMT
Hello -

Thanks for your help.  I was actually looking for VBA code to do this
via a macro but your comments are also very helpful as I have to do
something within the document as well.

Here is the VBA code somebody posted at
microsoft.public.word.programming ...

Dim oTable as Table
Dim oHeading as Range

For Each oTable in ActiveDocument.Tables
 oTable.Range.Select
 Set oHeading =
ActiveDocument.Bookmarks("\HeadingLevel").Range.Paragraphs.First.Range
 Debug.Print oHeading.ListFormat.ListString, oHeading.Text
Next oTable

Thanks again ...
Joe

> If you are trying to reference the current Heading 2 paragraph, you
> can use a STYLEREF field: { STYLEREF 2 \s }. Do the following to
[quoted text clipped - 43 lines]
> > Thanks!
> > Joe
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.