Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-04-2013, 04:01 AM
lsmcal1984 lsmcal1984 is offline Macro to create list of acronyms Windows XP Macro to create list of acronyms Office 2003
Novice
Macro to create list of acronyms
 
Join Date: Aug 2013
Posts: 18
lsmcal1984 is on a distinguished road
Default Macro to create list of acronyms

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!
Reply With Quote
  #2  
Old 09-04-2013, 06:08 AM
gmaxey gmaxey is offline Macro to create list of acronyms Windows 7 32bit Macro to create list of acronyms Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,600
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 09-04-2013, 07:20 AM
lsmcal1984 lsmcal1984 is offline Macro to create list of acronyms Windows XP Macro to create list of acronyms Office 2003
Novice
Macro to create list of acronyms
 
Join Date: Aug 2013
Posts: 18
lsmcal1984 is on a distinguished road
Default

This is great, thanks!
How can I add the page number to the results?
Reply With Quote
  #4  
Old 09-04-2013, 07:33 AM
gmaxey gmaxey is offline Macro to create list of acronyms Windows 7 32bit Macro to create list of acronyms Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,600
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to create list of acronyms How to create a automatically numbered list? three_jeeps Word 3 05-30-2013 10:53 AM
Macro to create list of acronyms Create list using VLOOKUP and IF? Ineedcoffee Excel 4 12-06-2011 01:49 AM
Macro to create list of acronyms Create a distribution list? 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

Other Forums: Access Forums

All times are GMT -7. The time now is 04:53 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft