posted
I need to develop an automated process in MS Word that will find text elements formatted with a CUSTOM style and list them at the bottom of the page.
posted
Yes. I'm trying to find some way to list all of the acronyms in a document, so the style will always be 'acronym.'
I've tried using the Index and Table dialogue, modifying the Figures of Tables to match with the style 'acronym,' but can't seem to get it to work...
Posts: 14554 | Registered: Dec 1999
| IP: Logged |
posted
Make a new momdule in your document with these contents. Then run it.
Change "ACRONYM" to whatever the style name is.
Be sure to work on a backup copy!
code:
Option Explicit
Sub GetAllWordsWithStyle() Dim rng As Range Dim itemlist As New Collection Dim itm As Variant
For Each rng In ActiveDocument.Words If rng.Style = "ACRONYM" Then Debug.Print rng.Text itemlist.Add rng.Text End If Next rng
Set rng = ActiveDocument.Range rng.Collapse wdCollapseEnd rng.InsertAfter vbCrLf & "Acronyms:" For Each itm In itemlist rng.Collapse wdCollapseEnd rng.InsertAfter vbCrLf & itm Next itm End Sub
posted
I found a temporary work around, as below (this is with Word 2003-- not sure how to do this on any earlier versions).
Before you start writing a doc, create a style called ‘acronym.’ Whenever you add an acronym, select it, and change its style to ‘acronym.’ When you’re ready to insert the Table of Acronyms, click the style button (looks like Aa), and you should see all the Styles available in the document appear on the right side of the screen. Click ‘acronym’ and then click ‘Select all X instances.’ All the words with the style ‘acronym’ will be selected—you can then copy and paste them into a vertical list.
Posts: 14554 | Registered: Dec 1999
| IP: Logged |