Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 06-10-2022, 04:27 PM
Charles Kenyon Charles Kenyon is offline How to replace WordBasic.AutoCorrectNow in an old macro? Windows 10 How to replace WordBasic.AutoCorrectNow in an old macro? Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,583
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

When I run this, it seems to require selecting the text that should trigger AutoCorrect and then running the macro for that term. It does not work if I select a block of text and run it. Here is one that Hans Vogelar tweaked for me based on it. It is not perfect but covers everything in the attached sample document.
Code:
  Sub AutoCorrectNow2()
      ' Graham Mayor Bob Sundquist, Hans Vogelar and Charles Kenyon 2022-06-10
      ' https://eileenslounge.com/viewtopic.php?f=26&t=38297&p=296123#p296123
      ' https://www.msofficeforums.com/word-vba/29148-how-replace-wordbasic-autocorrectnow-old-macro.html
      ' Runs autocorrect on selected text as if it were being retyped
      '
      '
      Dim oWrd   As range
      Dim Entry  As Object
      Dim iCount As Long, i As Long
      On Error Resume Next
      Let iCount = Selection.Words.Count
      For i = 1 To iCount
          Set oWrd = Selection.Words(i)
          For Each Entry In Word.Application.AutoCorrect.Entries
              If oWrd.Text = Entry.Name Then
                  oWrd.Text = Entry.Value
                  Exit For
              ElseIf oWrd.Text = Entry.Name & " " Then
                  oWrd.Text = Entry.Value & " "
                  Exit For
              End If
          Next Entry
      Next i
      Set oWrd = Nothing
      Set Entry = Nothing
   End Sub

This will only handle single-word entries.
Attached Files
File Type: docx deleteme AutoCorrectNow Macro.docx (20.3 KB, 7 views)
Reply With Quote
 

Tags
autocorrectnow



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro on Search and Replace davidhuy Word VBA 1 12-19-2014 04:47 AM
Need Macro to Replace Text rsrasc Word VBA 2 11-10-2014 06:26 PM
Windows 95 WordBasic (!!!) macro NobodysPerfect Word VBA 4 08-25-2014 02:03 AM
How to replace WordBasic.AutoCorrectNow in an old macro? Find and Replace Macro amparete13 PowerPoint 3 03-11-2014 05:29 AM
How to replace WordBasic.AutoCorrectNow in an old macro? Macro - replace with condition ubns Word VBA 1 05-02-2012 12:52 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:35 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft