Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Abbreviation Macro

33 views
Skip to first unread message

Tariq Allana

unread,
Dec 8, 2007, 10:08:19 AM12/8/07
to
Hello -

I am new to the word of Word macros, and so would appreciate any
help. I would like to create a macro that would help me with
abbreviations in a document.

So the macro should:

1. Prompt me to enter, in an input box the full form and abbreviation.
2. Replace all occurrences of the full form with the abbreviation.
3. Locate in the document the first occurrence of the abbreviation and
define it - that is at the first occurrence of the abbreviation, the
text should read - full form (abbreviation).
4. Create a separate document that has a list of all the abbreviations
and full forms.

Any help would be appreciated.

I am using Word XP/2003.

Thanks,
Tariq

I have been able to find in user groups code for 1, 2 and for part of
4, but not 3.

Code for 1 and 2 - Tested by me - and works

Sub abbreviation()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = InputBox("Full form: ", "Full form")
.Wrap = wdFindAsk
.Replacement.Text = InputBox("Type Abbreviation here: ",
"Abbreviation")
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With

For 4 - I found, but have not tested:

Dim SourceDoc As Document, ListDoc As Document, aword As Range
Set SourceDoc = ActiveDocument
Set ListDoc = Documents.Add
For Each aword In SourceDoc.Words
If aword.Case = wdUpperCase Then
ListDoc.Range.InsertAfter aword & vbCr
End If
Next aword
ListDoc.Range.Sort

Anand.V.V.N

unread,
Jan 18, 2008, 11:39:01 AM1/18/08
to
Hello,
For the 4th step, you can loop you and count the occurance for that, when
the counter is 1 it should be the first occurance, and read the full form.
Using the Documents.add method, you can add a new document, and to add the
text you want you can use the activedocument.content.insertafter text, using
a loop which would insert each text, and then you can save the document using
the activedocument.save method to save the document.

Hope this is helpful
--
"Who will guard the guards?"


"Tariq Allana" wrote:

> ..Text = InputBox("Full form: ", "Full form")
> ..Wrap = wdFindAsk
> ..Replacement.Text = InputBox("Type Abbreviation here: ",

0 new messages