![]() |
#1
|
|||
|
|||
![]()
Hi all,
Is it possible to create a macro that generates a list of acronyms in a new (separate) document? All acryonms in the document are in uppercase and consist of 2, 3, 4 or 5 letters. This would be used to create a glossary at the end of the document so I'd only like each acronym to occur once in the list. Many thanks! |
#2
|
|||
|
|||
![]()
Should get you close:
Code:
Sub ScratchMacro() 'A basic Word macro coded by Greg Maxey Dim oCol As New Collection Dim oRng As Word.Range Dim oDoc As Word.Document Dim lngIndex As Long Set oRng = ActiveDocument.Range With oRng.Find .Text = "<[A-Z]{1,5}>" .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 = Documents.Add For lngIndex = 1 To oCol.Count oDoc.Range.InsertAfter oCol(lngIndex) & vbCr Next lngIndex End Sub |
#3
|
|||
|
|||
![]()
This is great, thanks!
How can I add the page number to the results? |
#4
|
|||
|
|||
![]() Code:
Sub ScratchMacro() 'A basic Word macro coded by Greg Maxey Dim oCol As New Collection Dim oColPN As New Collection Dim oRng As Word.Range Dim oDoc As Word.Document Dim lngIndex As Long Set oRng = ActiveDocument.Range With oRng.Find .Text = "<[A-Z]{1,5}>" .MatchWildcards = True While .Execute On Error Resume Next oCol.Add oRng.Text, oRng.Text If Err.Number = 0 Then oColPN.Add oRng.Information(wdActiveEndPageNumber) End If On Error GoTo 0 oRng.Collapse wdCollapseEnd Wend End With Set oDoc = Documents.Add For lngIndex = 1 To oCol.Count oDoc.Range.InsertAfter oCol(lngIndex) & " " & oColPN(lngIndex) & vbCr Next lngIndex End Sub |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
three_jeeps | Word | 3 | 05-30-2013 10:53 AM |
![]() |
Ineedcoffee | Excel | 4 | 12-06-2011 01:49 AM |
![]() |
Emerogork | Outlook | 2 | 08-25-2011 09:04 PM |
Create Drop Down List Box | hbradshaw | Word VBA | 0 | 09-27-2010 06:24 AM |
How do you create a list similar to an itunes list? | hatemail13 | Excel | 1 | 08-06-2010 02:21 AM |