Accelerator (or Macro) to automate creation of new AutoCorrect entries in MS Word 2010?

Hello all.  I searched through the FAQs and other info here and found plenty of useful tips (thanks!) but here is something I would like to find: code for an Accelerator or macro to quickly enter AutoCorrect entries on the fly.  I am a government worker (yeah, I know...) and use hundreds if not thousands of acronyms.  I've tried various add-ons and utilities (RoboType was my favorite) but now we're prevnted from running additonal programs on the government PCs.  I can still do macros and such, though.

Has anyone created something like this:  You are reading a document and run across a phrase you want to store as an AutoCorrect entry.  You highlight the text you want to keep, for example, "U.S. Government (USG)" and either right-click for a contect menu action or hit a defined macro key.  That would trigger an action to automatically bring up and populate a new AutoCorrect definition, let you make final adjustments, and have you enter the 'trigger text'.  I tend to use the character ` followed by the acronym such as "`USG".  After that I can simply use `USG if I want to type the phrase "U.S. Government (USG)" into a document.

I've assigned a hot-key to bring up the AutoCorrect dialogue and that works OK.  It's rather trivial to do.  But it would be very nice to take this one step further take highlighted text and have it automatically populate the field for a new AutoCorrect entry.  An Acceleartor that worked when right-clicking highlighted text would be awesome, too.

Thank you.

/Sam/

Answer
Answer

Sam, I don't think it's going to get much better than what you're already doing.


The difficulty is that the entries (assuming they're plain text, not what Office considers "formatted" entries) get stored in a language-dependent ACL file -- for US English, that would be %appdata%\Microsoft\Office\MSO1033.ACL. The ACL files are mostly Unicode text, but interspersed with binary bits.


Unless you know how to write a program that properly manages the binary parts of the file, you have to let Word add and delete the entries.


The best I can offer you is this idea: You can have a shortcut key that starts Word and automatically opens the AutoCorrect dialog. If all goes well, the text content of the clipboard will be in the "With" box.

Insert this macro in your Normal.dotm template (see http://www.gmayor.com/installing_macro.htm if necessary):

Sub AutoCorrectDialog()
    Dim MyData As DataObject
    Set MyData = New DataObject
    On Error GoTo BadData
    MyData.GetFromClipboard
    With Dialogs(wdDialogToolsAutoCorrect)
        .With = MyData.GetText
        .Show
    End With
    GoTo Finally
BadData:
    MsgBox "The clipboard does not contain text.", vbCritical, "Error"
Finally:
    Set MyData = Nothing
End Sub

While you're still in the macro editor, click the Tools menu, click References, and put a check mark next to "Microsoft Forms 2.0 Object Library". That's necessary to let VBA use the DataObject. Save the template and close the macro editor.

Locate your Word executable file, WinWord.exe, which is probably in the folder C:\Program Files\Microsoft Office\Office14. Right-click the file and click Send To > Desktop (create shortcut).

When the shortcut appears on your desktop, right-click it and click Properties. On the Shortcut tab of the Properties dialog, click at the end of the path in the Target box (after the closing quote mark), type a space, and type /mAutoCorrectDialog. Then click in the Shortcut key box and press the key combination you want to use to start Word and invoke the macro. Finally, click OK.

When you press the shortcut key combination, a new instance of Word will start. (If you already have Word running, you'll now have two separate copies of Word.) The AutoCorrect dialog will immediately open, with the copied text in the "With" box and the cursor in the "Replace" box. The remaining steps are manual -- entering the Replace text, clicking OK, and closing the instance of Word.

_____________________________
https://jay-freedman.info

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated April 11, 2023 Views 417 Applies to: