FacebookTwitter
Hatrack River Forum   
my profile login | search | faq | forum home

  next oldest topic   next newest topic
» Hatrack River Forum » Active Forums » Books, Films, Food and Culture » MS Word assistance

   
Author Topic: MS Word assistance
Scott R
Member
Member # 567

 - posted      Profile for Scott R   Email Scott R         Edit/Delete Post 
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.

[Smile]

Any takers?

Posts: 14554 | Registered: Dec 1999  |  IP: Logged | Report this post to a Moderator
TomDavidson
Member
Member # 124

 - posted      Profile for TomDavidson   Email TomDavidson         Edit/Delete Post 
Will the custom style always have the same name?
Posts: 37449 | Registered: May 1999  |  IP: Logged | Report this post to a Moderator
Scott R
Member
Member # 567

 - posted      Profile for Scott R   Email Scott R         Edit/Delete Post 
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 | Report this post to a Moderator
Dagonee
Member
Member # 5818

 - posted      Profile for Dagonee           Edit/Delete Post 
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


Posts: 26071 | Registered: Oct 2003  |  IP: Logged | Report this post to a Moderator
Scott R
Member
Member # 567

 - posted      Profile for Scott R   Email Scott R         Edit/Delete Post 
Dag:

Thanks-- but the code doesn't seem to do anything but print out the word 'Acronyms:'

I made sure to name the style ACRONYM. . .

?

Posts: 14554 | Registered: Dec 1999  |  IP: Logged | Report this post to a Moderator
Scott R
Member
Member # 567

 - posted      Profile for Scott R   Email Scott R         Edit/Delete Post 
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 | Report this post to a Moderator
Dagonee
Member
Member # 5818

 - posted      Profile for Dagonee           Edit/Delete Post 
Then there were no words using that style in the document. I beleive style names are case sensitive.

Glad you found a way to do it, though.

Posts: 26071 | Registered: Oct 2003  |  IP: Logged | Report this post to a Moderator
   

   Close Topic   Feature Topic   Move Topic   Delete Topic next oldest topic   next newest topic
 - Printer-friendly view of this topic
Hop To:


Contact Us | Hatrack River Home Page

Copyright © 2008 Hatrack River Enterprises Inc. All rights reserved.
Reproduction in whole or in part without permission is prohibited.


Powered by Infopop Corporation
UBB.classic™ 6.7.2