Thread: Table Tagging
View Single Post
 
Old 02-21-2022, 09:44 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

Try this code
Code:
Sub TagTables()
  Dim aTbl As Table, bSkip As Boolean, iCount As Integer, i As Integer
  iCount = ActiveDocument.Tables.Count
  For i = 1 To iCount
    Set aTbl = ActiveDocument.Tables(i)
    aTbl.Select
    If Not bSkip Then
      aTbl.Range.Previous(Unit:=wdCharacter, Count:=1).InsertBefore vbCr & "AAA"
      bSkip = MsgBox("Yes to Extend tag, No to close tag", vbYesNo) = vbYes
      If Not bSkip Then aTbl.Range.Next(Unit:=wdCharacter, Count:=1).InsertBefore "BBB" & vbCr
    Else
      bSkip = MsgBox("Yes to Extend tag, No to close tag", vbYesNo) = vbYes
      If bSkip = False Then
        aTbl.Range.Next(Unit:=wdCharacter, Count:=1).InsertBefore "BBB" & vbCr
      End If
      If i = iCount - 1 Then bSkip = False
    End If
  Next i
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote