Re: Script to Capture Data in Document by Art
Art
Tue Jun 14 15:00:07 CDT 2005
Doug Robbins,
Thanks for the code!
Having to work with multiple authors on large technical documents, I can
appreciate what Bill has to deal with. What was really interesting was the
results I got when I tested the Marco on a document I had on hand. The Marco
did everything that you said it would, However, the results were less than
what I expected. So I changed FindText:="\([A-Z]{2,}\)" to
FindText:="[A-Z]{2,}". By removing the (), the Marco listed everything it
found with two or more uppercase letters. This allowed me to see how many
Acronyms were being used but not presented correctly....ART
"Doug Robbins" wrote:
> If you just want to create a list of the acronyms at the end of the document
> (without their definition), then run the following macro:
>
> Dim myrange As Range
> Selection.HomeKey wdStory
> Selection.Find.ClearFormatting
> With Selection.Find
> While .Execute(FindText:="\([A-Z]{2,}\)", MatchWildcards:=True,
> Wrap:=wdFindStop, Forward:=True) = True
> Set myrange = Selection.Range
> ActiveDocument.Range.InsertAfter myrange & vbCr
> Wend
> End With
>
>
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP
> "Bilbert" <Bilbert@discussions.microsoft.com> wrote in message
> news:01592B79-FAAC-49A1-93D0-62EF2F2073A2@microsoft.com...
> > Thank you for your reply Doug, I appreciate it. However, I must confess
> > that
> > I did not understand it. I probably need to explain it easier and not make
> > it
> > so complex. I'd just like to scan through a document and build a list of
> > uppercase items between parens. i.e., (COTS).
> >
> > Sorry for the confussion. Bill
> >
> > "Doug Robbins" wrote:
> >
> >> The following code will do part of what you want - copy from the
> >> beginning
> >> of the line on which and Acronym up to the end of the acronym and paste
> >> that
> >> string into a new document. You would then of course have to edit out
> >> anything at the beginning of the line that you did not need (or add to it
> >> something that got missed because it was on the previous line). You
> >> could
> >> then use find and replace to remove the ) for the text in the new file
> >> and
> >> use Convert Text to table selecting the ( as the separator to create a
> >> table
> >> containing the definition and its acronym. You can then cut the column
> >> containing the acronyms and paste it in front of the one containing the
> >> definitions.
> >>
> >> Dim myrange As Range, Source As Document, Target As Document
> >> Set Source = ActiveDocument
> >> Set Target = Documents.Add
> >> Source.Activate
> >> Selection.HomeKey wdStory
> >> Selection.Find.ClearFormatting
> >> With Selection.Find
> >> While .Execute(FindText:="\([A-Z]{2,}\)", MatchWildcards:=True,
> >> Wrap:=wdFindStop, Forward:=True) = True
> >> Set myrange = Selection.Range
> >> myrange.Start = myrange.Bookmarks("\line").Range.Start
> >> Target.Range.InsertAfter myrange & vbCr
> >> Wend
> >> End With
> >>
> >>
> >> --
> >> Hope this helps.
> >>
> >> Please reply to the newsgroup unless you wish to avail yourself of my
> >> services on a paid consulting basis.
> >>
> >> Doug Robbins - Word MVP
> >> "Bilbert" <Bilbert@discussions.microsoft.com> wrote in message
> >> news:68D1B59D-E69A-4DF7-9B88-D30CD6A73D92@microsoft.com...
> >> > Greetings - Let me say first that at best I consider myself an
> >> > intermediate
> >> > user of MS Office tools and that I am willing to try and learn
> >> > anything.
> >> >
> >> > I am composing a large document ion Word that requires a list of
> >> > acronyms,
> >> > which are used in the document, to be added at the end. I am not much
> >> > of a
> >> > programmer, but wonder if a script/macro (VBA?) could be written and
> >> > manually
> >> > executed when complete with the document, via a tool bar button from
> >> > the
> >> > template, to scan the document checking for items that have either 3 or
> >> > 4
> >> > uppercase characters enclosed within parentheses. i.e., "(COTS)"
> >> >
> >> > It would then check and capture the 3 or 4 words (which are Title
> >> > Cap'd)
> >> > prior to the open parens and copy it adjacent to the acronym in the
> >> > table.
> >> > i.e., "We use Commercial off-the-Shelf (COTS) applications."
> >> >
> >> > After capturing the data, the macro would list all items in a table and
> >> > sort. i.e., "COTS - Commercial off-the-Shelf"
> >> >
> >> > The idea here is to eliminate the need for an editor or author to
> >> > continually build a list of items used in the document and to ensure
> >> > only
> >> > items which are used are recorded in the subsequent table.
> >> >
> >> > Any thoughts or suggestions would be greatly appreciated. Thank you in
> >> > advance for your assistance. Bill
> >> >
> >>
> >>
> >>
>
>
>