dfoster
06-29-2016, 09:48 PM
Hi all,
I'm trying to figure out a way to find all abbreviations in a selected table and then list the abbreviations directly beneath that table. I feel like I'm close, but for some reason all abbreviations for all tables are listed. How do I specify the range as the selected table?
Here is what I have so far:
Dim oCol As New Collection
Dim oRng As Range
Dim oDoc As Word.Document
Dim lngIndex As Long
Set oRng = Selection.Range
Selection.Collapse WdCollapseDirection.wdCollapseEnd
With oRng.Find
.Text = "<[A-Z]{1,8}>"
.MatchWildcards = True
While .Execute
On Error Resume Next
oCol.Add oRng.Text, oRng.Text
On Error GoTo 0
oRng.Collapse wdCollapseEnd
Wend
End With
Set oDoc = ActiveDocument
Set oRng = Selection.Range
For lngIndex = 1 To oCol.Count
Selection.InsertAfter oCol(lngIndex) & vbCr
Next lngIndex
End Sub
Thanks in advance for any help you can provide. Thanks also to Greg Maxey for helping me get started.
I'm trying to figure out a way to find all abbreviations in a selected table and then list the abbreviations directly beneath that table. I feel like I'm close, but for some reason all abbreviations for all tables are listed. How do I specify the range as the selected table?
Here is what I have so far:
Dim oCol As New Collection
Dim oRng As Range
Dim oDoc As Word.Document
Dim lngIndex As Long
Set oRng = Selection.Range
Selection.Collapse WdCollapseDirection.wdCollapseEnd
With oRng.Find
.Text = "<[A-Z]{1,8}>"
.MatchWildcards = True
While .Execute
On Error Resume Next
oCol.Add oRng.Text, oRng.Text
On Error GoTo 0
oRng.Collapse wdCollapseEnd
Wend
End With
Set oDoc = ActiveDocument
Set oRng = Selection.Range
For lngIndex = 1 To oCol.Count
Selection.InsertAfter oCol(lngIndex) & vbCr
Next lngIndex
End Sub
Thanks in advance for any help you can provide. Thanks also to Greg Maxey for helping me get started.