An
MT friend named Harrie, who likes
the ABCZ rule for
two-word phrases (abab), suggested
a macro
to
select two-word phrases for entry
into Instant Text when building a glossary. Ed Weber graciously
wrote
the macro, and a few more
for Word, which are shown below. (BTW, Harrie has opened the
very useful Productivity
Talk forum)
1.
Word Macro: Selects previous two
words and makes an entry in AUTOCORRECT in the form of
first
two letters of each word.
Works with Word 2000 and higher. Idea by Harrie. Macro by Ed
Weber.
Sub
Send_Selection_to_AutoCorrect()
'Code
by Ed Weber
Dim
strShortForm As String
Dim
oACEntry As AutoCorrectEntry
'Select
the last two words
Selection.MoveLeft
Unit:=wdWord,
Count:=2, Extend:=wdExtend
'make
strShortForm = first two letters
of each word
strShortForm
= LCase(Left(Selection.Words(1).Text,
2) & _
Left(Selection.Words(2).Text,
2))
For
Each oACEntry In AutoCorrect.Entries
'check
for existing entry
If
oACEntry.Name = strShortForm
Then
Response
= MsgBox("The autocorrect
name '" & strShortForm & "' with a value of '"
& _
oACEntry.Value
& "' already
exists." & vbCr & _
"Do
you want to overwrite this entry?",
vbYesNo, "AutoCorrect Macro ")
If
Response = vbNo Then End
Exit
For
End If
Next
oACEntry
AutoCorrect.Entries.Add
Name:=strShortForm,
Value:=Selection.Text
End Sub
2.
Word Macro: Selects previous two
words for entry into current INSTANT TEXT glossary.
Works
with Word 2000 and higher.
Idea by Harrie. Macro by Ed
Weber.
Sub
Select_and_Send_to_IT()
'code
by Ed Weber 03/07/04
'Place
the cursor immediately to
the right of the two target words.
'The
macro will select the two words
to the left of the cursor
'then
activate Instant Text.
Selection.MoveLeft
Unit:=wdWord,
Count:=2, Extend:=wdExtend
SendKeys
"%="
End Sub
3.
Word Macro: Selects previous word
for entry into current INSTANT TEXT glossary.
Works
with Word 2000 and higher.
Idea by Harrie. Macro by Ed Weber.
Sub
Select_One_and_Send_to_IT )
'code
by Ed Weber 03/07/04
'Select
the last word
Selection.MoveLeft
Unit:=wdWord,
Count:=1, Extend:=wdExtend
'activate
Instant Text
SendKeys
"%="
End Sub
4.
Word Macro: Removes 1 or 2 spaces
after the decimal point in a number. Works with Word 2000
and
higher. Macro by Ed Weber.
Sub
Delete_Space_After_Decimal_Point()
'code
by Ed Weber
'Will
remove one or two spaces after
the
'decimal
point in a number.
Dim
rngdoc As range
Dim
rngFind As range
Dim
Count As Long
Dim
blSmartCutPaste As Boolean
Dim
Iteration As Integer
Count
= 0
'Remember
SmartCutandPaste setting
then
'make
it false
blSmartCutPaste
= Options.SmartCutPaste
Options.SmartCutPaste
= False
'Process
one space after decimal
point during
'the
first iteration then process
two spaces
'after
decimal point during the
second iteration
For
Iteration = 1 To 2
Set rngdoc = ActiveDocument.range.Duplicate
With rngdoc.Find
.ClearFormatting
If Iteration = 1 Then
.Text = "[0-9].
[0-9]"
Else
.Text = "[0-9].
[0-9]"
End If
.MatchWildcards = True
.Wrap = wdFindContinue
While .Execute
If .Found Then
Count = Count + 1
Set rngFind =
rngdoc.Duplicate
rngFind.SetRange
Start:=rngFind.Start + 2, _
End:=rngFind.End
- 1
rngFind.Delete
Wend
End With
Next
Iteration
'Restore
SmartCutandPast setting
Options.SmartCutPaste
= blSmartCutPaste
'Show
the results
MsgBox
str(Count) & " changes
made.", vbOKOnly, "Macro by Ed Weber"
End Sub