View Single Post
 
Old 09-21-2017, 07:17 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The table count can be obtained with:
ActiveDocument.Tables.Count

A loop in VBA might be constructed with code like:
Code:
Sub Demo1()
Dim i As along
With ActiveDocument
  For i = 1 To .Tables.Count
    'process the table
    With .Tables(i)
    'table processing code goes here
    End With
    'or, perhaps:
    .Tables(i).Range.Copy
  Next
End With
End Sub
or:
Code:
Sub Demo2()
Dim Tbl As Table
For Each Tbl In ActiveDocument.Tables
  'process the table
  With Tbl
    'table processing code goes here
  End With
  'or, perhaps:
  Tbl.Range.Copy
Next
End Sub
Note how the second one doesn't need to table count.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote