Hi
This query was originally posted in the Office Forum ( but I have beed advised to move it here.
A user has created a long list of AutoCorrect entries that were supposed to be AutoText entries (Word 2002). Each entry begins with a '/' so the following code was created for me by Tek-Tips user 'fumei' to export the entries to AutoText:
-------------------------------------
CODE
Sub myAutoCorrect()
Dim myTemplate As Word.Template
Dim myAC As Word.AutoCorrectEntry
Set myTemplate = ActiveDocument.AttachedTemplate
For Each myAC In Application.AutoCorrect.Entries()
If Left(myAc.Name, 1) = "/" Then
Selection.TypeText myAC.Value & vbCrLf
With Selection
.Previous(Unit:=wdParagraph, Count:=1).Select
.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
End With
myTemplate.AutoTextEntries.Add Name:=myAC.Name, _
Range:=Selection.Range
End If
Next
Set myTemplate = Nothing
End Sub
-------------------------------------
This has worked, but only the last line appears in the AutoText
For example:
Autocorrect Entry: "/123 Abc St" is "123 Abc Street*LONDON*SW18**BY FAX AND DX 020 7123 4567" (the '*'s are returns/new lines).
When converted to AutoText it is just "**BY FAX AND DX 020 7123 4567".
Any Suggestions?
Thanks
This query was originally posted in the Office Forum ( but I have beed advised to move it here.
A user has created a long list of AutoCorrect entries that were supposed to be AutoText entries (Word 2002). Each entry begins with a '/' so the following code was created for me by Tek-Tips user 'fumei' to export the entries to AutoText:
-------------------------------------
CODE
Sub myAutoCorrect()
Dim myTemplate As Word.Template
Dim myAC As Word.AutoCorrectEntry
Set myTemplate = ActiveDocument.AttachedTemplate
For Each myAC In Application.AutoCorrect.Entries()
If Left(myAc.Name, 1) = "/" Then
Selection.TypeText myAC.Value & vbCrLf
With Selection
.Previous(Unit:=wdParagraph, Count:=1).Select
.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
End With
myTemplate.AutoTextEntries.Add Name:=myAC.Name, _
Range:=Selection.Range
End If
Next
Set myTemplate = Nothing
End Sub
-------------------------------------
This has worked, but only the last line appears in the AutoText
For example:
Autocorrect Entry: "/123 Abc St" is "123 Abc Street*LONDON*SW18**BY FAX AND DX 020 7123 4567" (the '*'s are returns/new lines).
When converted to AutoText it is just "**BY FAX AND DX 020 7123 4567".
Any Suggestions?
Thanks