Import/Export Auto Correct Entries from Word

I used this script once to do a mass update an organizations auto correct entries.

I exported the entries, gave them to the customer who edited the list, then I reimported the entries back in. The acl file was then distributed to all the users.

Sub ExportAutoCorrectEntries()
On Error GoTo Err_Handler
    Const fileName As String = "C:\temp\AutoCorrect.csv"
    Dim i As Integer
    Dim ent As AutoCorrectEntry
    
    Open fileName For Output As #1

    For Each ent In AutoCorrect.Entries
        Write #1, ent.Name, ent.Value
    Next ent

Exit_Proc:
    Close #1
    Exit Sub
Err_Handler:
    MsgBox ("Error: " & Error)
    Resume Exit_Proc
End Sub
Public Sub ImportAutoCorrectEntries()
On Error GoTo Err_Handler
    Dim objExcel As excel.Application
    Dim sheet As excel.Worksheet
    Dim row As Long
  
    Const FILE_NAME As String = "C:\temp\AutoCorrect.xlsx"
    Const MAX_ROWS As Long = 10000 ' change if you need to
    
    Set objExcel = New excel.Application
    
    Set sheet = objExcel.Workbooks.Open(FILE_NAME).Worksheets(1)
    
    For row = 1 To MAX_ROWS
        If sheet.Cells(row, 1) = "" Then
            row = MAX_ROWS
        Else
            Call AutoCorrect.Entries.Add(sheet.Cells(row, 1), sheet.Cells(row, 2))
        End If
    Next row
    
Exit_Proc:
    Exit Sub
Err_Handler:
    MsgBox ("Error: " & Error)
    Resume Exit_Proc
End Sub

Comments

The export doesn’t seem to include the macrons (accents). Might be the write method.

Because the customer gave me back an Excel file I am using the Microsoft Excel Object Library reference.

An auto correct entry can be entered more than once with no effect. I tried multiple times and only one entry was ever saved in the list.

In Word 2010 and 2016 the Auto Correct file (acl) is in “%userprofile%\AppData\Roaming\Microsoft\Office\ – Look at the date modified.

Leave a Reply

Your email address will not be published. Required fields are marked *