Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.tables
TimvG TimvG is offline
external usenet poster
 
Posts: 12
Default Recursive procedure for nested tables


Suppose you have nested tables, with the nesting going arbitrarily
deep. You want to do something to every table. It seems that it
would be sensible to use a recursive procedure.

Does anyone have/know of any examples of recursive procedures for
working with nested tables?

Or is there any reason this can't be done?
  #2   Report Post  
Posted to microsoft.public.word.tables
TimvG TimvG is offline
external usenet poster
 
Posts: 12
Default Recursive procedure for nested tables

Well, let me be first to reply... It can certainly be done. I can
share some example code if there's interest.

On Dec 9, 4:38*pm, TimvG wrote:
Suppose you have nested tables, with the nesting going arbitrarily
deep. *You want to do something to every table. *It seems that it
would be sensible to use a recursive procedure.

Does anyone have/know of any examples of recursive procedures for
working with nested tables?

Or is there any reason this can't be done?


  #3   Report Post  
Posted to microsoft.public.word.tables
Greg Maxey[_2_] Greg Maxey[_2_] is offline
external usenet poster
 
Posts: 668
Default Recursive procedure for nested tables

Tim,

This is what I use. The example adds a red border to a specific cell in
each main and nested table:

Sub FormatTables()
Dim oTbl As Table
Dim oCell As Word.Cell
For Each oTbl In ActiveDocument.Tables
ProcessTable oTbl 'Process main table
'Call recursive function to process nested tables
RecursiveLoop oTbl
Next
End Sub

Function RecursiveLoop(ByRef oTblParent As Word.Table, Optional oTblChild As
Word.Table)
Dim oCellNested As Word.Cell
Dim oTblNested As Word.Table
Dim i As Long
For Each oCellNested In oTblParent.Range.Cells
If oCellNested.Tables.Count 0 Then
For i = 1 To oCellNested.Tables.Count
Set oTblNested = oCellNested.Tables(i)
Set oTblParent = oTblNested
ProcessTable oTblNested
RecursiveLoop oTblNested, oTblParent
Next i
End If
Next oCellNested
End Function

Sub ProcessTable(oTblSingle As Table)
oTblSingle.Cell(1, 3).Borders.OutsideColorIndex = wdRed
End Sub


"TimvG" wrote in message
...
Well, let me be first to reply... It can certainly be done. I can
share some example code if there's interest.

On Dec 9, 4:38 pm, TimvG wrote:
Suppose you have nested tables, with the nesting going arbitrarily
deep. You want to do something to every table. It seems that it
would be sensible to use a recursive procedure.

Does anyone have/know of any examples of recursive procedures for
working with nested tables?

Or is there any reason this can't be done?



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Nested Tables Ward Tables 3 November 20th 09 12:05 AM
Nested Tables and Corruption Rene Tables 1 October 17th 07 06:12 PM
For the archive, code to format (styles and column widths) tables and nested tables kbutterly Tables 0 January 24th 07 03:00 PM
Tables storing results of Stored Procedure Edward Li Tables 0 August 3rd 05 11:19 AM
Help with nested tables Anasazi Tables 2 March 18th 05 05:42 AM


All times are GMT +1. The time now is 08:14 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"