Thread: Table Tagging
View Single Post
 
Old 03-15-2022, 04:51 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Assuming you want to start from the current selection position.
Code:
Sub TagTables2()
  Dim aTbl As Table, bSkip As Boolean, iCount As Integer, i As Integer, aRng As Range
  Set aRng = ActiveDocument.Range(Selection.Start, ActiveDocument.Range.End)
  bSkip = False
  iCount = aRng.Tables.Count
  For Each aTbl In aRng.Tables
    i = i + 1
    aTbl.Select
    If bSkip = False Then aTbl.Range.Previous(Unit:=wdCharacter, Count:=1).InsertBefore vbCr & "AAA"
    bSkip = MsgBox("Yes to Extend tag, No to stop and close tag", vbYesNo) = vbYes
    If i = iCount Or Not bSkip Then
      aTbl.Range.Next(Unit:=wdCharacter, Count:=1).InsertBefore "BBB" & vbCr
      Exit For
    End If
  Next aTbl
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote