dfoster
08-18-2016, 06:34 AM
I could really use some help. I posted a similar question here not too long ago and am once again tearing my hair out trying to get my macros figured out.
I am trying to select a paragraph and compile a list of abbreviations to be inserted at the end of the selected paragraph. For some reason, I'm getting a list of all abbreviations through to the end of the document.
Here is what I have so far:
Dim oCol As New Collection
Dim oRng As Word.Range
Dim oDoc As Word.Document
Dim lngIndex As Long
Set oRng = Selection.Range
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
For lngIndex = 1 To oCol.Count
Selection.InsertAfter oCol(lngIndex) & "," & " " & "; "
Next lngIndex
End Sub
Help would be much appreciated.
I am trying to select a paragraph and compile a list of abbreviations to be inserted at the end of the selected paragraph. For some reason, I'm getting a list of all abbreviations through to the end of the document.
Here is what I have so far:
Dim oCol As New Collection
Dim oRng As Word.Range
Dim oDoc As Word.Document
Dim lngIndex As Long
Set oRng = Selection.Range
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
For lngIndex = 1 To oCol.Count
Selection.InsertAfter oCol(lngIndex) & "," & " " & "; "
Next lngIndex
End Sub
Help would be much appreciated.