G
Gary O
I'm wanting to maintain global AutoCorrect details for my workplace which has
four PC's. I have found the following link which is what I want to do:
http://wordtips.vitalnews.com/Pages/T1408_Importing_AutoCorrect_Entries.html
However, when I copy the macro into Word and run the macro it does not add
the new AutoCorrect entries.
If the AutoCorrect entry exists in Word, it will ask me if I want to
overwrite it, so it seems that the second part of the macro is working.
I just can't work out how to get the first part working so that it will add
AutoCorrect details to Word.
This is the code for the Macro:
Sub AddToTheAutoCorrectList()
Dim r As Range, r1 As Range
Dim par As Paragraph, bo As Boolean
Dim pars As Paragraphs
Dim ACE As AutoCorrectEntry
Dim ACEs As AutoCorrectEntries
Dim ActD As Document
Set ActD = ActiveDocument
Set pars = ActD.Paragraphs
Set r1 = Selection.Range
Set r = Selection.Range
Set ACEs = Application.AutoCorrect.Entries
On Error Resume Next
For Each par In pars
If par.Range.End = ActD.Content.End Then Exit Sub
r1.Start = par.Range.Start
r1.End = r1.Start
r1.MoveEndUntil vbTab
r.Start = r1.End + 1
r.End = par.Range.End - 1
If Len(r1.Text) > 0 Or Len(r.Text) > 0 Then
If Len(ACEs(r1.Text).Value) > 0 Then
bo = Repl(ACEs, r, r1)
Else
bo = True
End If
If bo Then ACEs.Add r1.Text, r.Text
End If
Next
End Sub
Private Function Repl(a As AutoCorrectEntries, _
r As Range, r1 As Range) As Boolean
If a(r1.Text).Value <> r.Text Then
Repl = MsgBox("To replace " & UCase(a(r1.Text).Value) & _
" with " & UCase(r.Text) & " click OK", vbYesNo + _
vbQuestion, "REPLACE ENTRY?") = vbYes
End If
End Function
Any suggestions as to how I can get this macro to work?
four PC's. I have found the following link which is what I want to do:
http://wordtips.vitalnews.com/Pages/T1408_Importing_AutoCorrect_Entries.html
However, when I copy the macro into Word and run the macro it does not add
the new AutoCorrect entries.
If the AutoCorrect entry exists in Word, it will ask me if I want to
overwrite it, so it seems that the second part of the macro is working.
I just can't work out how to get the first part working so that it will add
AutoCorrect details to Word.
This is the code for the Macro:
Sub AddToTheAutoCorrectList()
Dim r As Range, r1 As Range
Dim par As Paragraph, bo As Boolean
Dim pars As Paragraphs
Dim ACE As AutoCorrectEntry
Dim ACEs As AutoCorrectEntries
Dim ActD As Document
Set ActD = ActiveDocument
Set pars = ActD.Paragraphs
Set r1 = Selection.Range
Set r = Selection.Range
Set ACEs = Application.AutoCorrect.Entries
On Error Resume Next
For Each par In pars
If par.Range.End = ActD.Content.End Then Exit Sub
r1.Start = par.Range.Start
r1.End = r1.Start
r1.MoveEndUntil vbTab
r.Start = r1.End + 1
r.End = par.Range.End - 1
If Len(r1.Text) > 0 Or Len(r.Text) > 0 Then
If Len(ACEs(r1.Text).Value) > 0 Then
bo = Repl(ACEs, r, r1)
Else
bo = True
End If
If bo Then ACEs.Add r1.Text, r.Text
End If
Next
End Sub
Private Function Repl(a As AutoCorrectEntries, _
r As Range, r1 As Range) As Boolean
If a(r1.Text).Value <> r.Text Then
Repl = MsgBox("To replace " & UCase(a(r1.Text).Value) & _
" with " & UCase(r.Text) & " click OK", vbYesNo + _
vbQuestion, "REPLACE ENTRY?") = vbYes
End If
End Function
Any suggestions as to how I can get this macro to work?