View Single Post
 
Old 09-10-2025, 04:08 PM
chrisjj chrisjj is offline Windows 7 64bit Office 97-2003
Competent Performer
 
Join Date: Aug 2025
Posts: 120
chrisjj is on a distinguished road
Default Word 2003: Has anyone had success in accessing nested tables in a macro?

Not me. Even the simplest task fails for me. The attached has no nested tables yes VBA reports it has one.

Code:
Option Explicit

Sub CountFirstLevelNestedRows()
    Dim tbl As Table
    Dim rw As row
    Dim c As cell
    Dim nestedCount As Long
    Dim nt As Table
    
    nestedCount = 0
    
    ' Loop through all tables in the document
    For Each tbl In ActiveDocument.Tables
        ' Check each row for nested tables
        For Each rw In tbl.Rows
            For Each c In rw.Cells
                ' If this cell contains nested tables (first-level)
                If c.Range.Tables.count > 0 Then
                        MsgBox "Nested table !"
                End If
            Next c
        Next rw
    Next tbl
End Sub


Any help appreciated before I spend more time up what looks like a garden path...

Thanks.
Attached Files
File Type: doc Nested table detect FALSE +VE!.doc (43.0 KB, 3 views)
Reply With Quote