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
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: ",