Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 01-17-2020, 08:03 AM
gmaxey gmaxey is offline Formatting Nested Tables Windows 10 Formatting Nested Tables Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Something like this might do for you:

Code:
Sub QuerryAllTables()
Dim oTbl As Table
Dim oRng As Range
  For Each oTbl In fcnCollectDocTables
    MsgBox "Cell count: " & oTbl.Range.Cells.Count & " - Nesting level:  & oTbl.NestingLevel"
  Next
lbl_Exit:
  Exit Sub
End Sub

Function fcnCollectDocTables(Optional ByVal oDoc As Document) As Collection
'Returns all tables (top level and nested) in one collection.
Dim colStack As New Collection
Dim oTbl As Table
  Set fcnCollectDocTables = New Collection
  If Documents.Count > 0 And oDoc Is Nothing Then
    Set oDoc = ActiveDocument
  Else
    GoTo lbl_Exit
  End If
  colStack.Add oDoc.Tables
  Do While colStack.Count > 0
    For Each oTbl In colStack(1)
      fcnCollectDocTables.Add oTbl
      If oTbl.Tables.Count > 0 Then colStack.Add oTbl.Tables
    Next
    colStack.Remove 1
  Loop
lbl_Exit:
  Exit Function
End Function
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to compile text from multiple tables into a cell in a nested table jrooney7 Word VBA 2 03-11-2019 07:55 AM
Removing KeepWithNext Formatting from Nested Tables? Jfedora Word VBA 3 06-06-2017 11:49 AM
Nested tables. Count rows NevilleT Word VBA 9 05-10-2017 05:22 AM
Formatting all tables knightmetal Word 2 09-10-2012 10:53 PM
Nested vlookup with varable tables! Dave Jones Excel 0 08-30-2012 09:15 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:09 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft