![]() |
#1
|
|||
|
|||
![]() I have used a Word Macro to highlight typos according to a word list (an Excel file). However, I turned on the track changes and the result did not change as a mark-up record because I used that Macro to check whether a document with 200 pages has any typos. I tried to add the open track changes function to the Macro, but it ran very slow, or it deleted the original typo and replaced a typo then highlighted it. Does anyone know how to just write another macro to change those highlighted texts into mark-up records? Then I can just click accept or reject. Thank you for reading this post. Code:
Option Explicit Sub PR() Dim Path As String Dim objExcel As Object Dim iCount As Integer Dim VChar(2000) As String Dim maxCount As Integer Dim RT As Boolean Path = "D:\macro\R.xlsx" RT = ActiveDocument.TrackRevisions ActiveDocument.TrackRevisions = False 'Highlight variant characters Set objExcel = CreateObject("Excel.Application") objExcel.Workbooks.Open Path For iCount = 2 To 2000 VChar(iCount) = objExcel.ActiveWorkbook.Sheets(1).Cells(iCount, 1) If objExcel.ActiveWorkbook.Sheets(1).Cells(iCount, 3) = "T" Then _ Selection.Find.MatchWildcards = True If Len(VChar(iCount)) = 0 Then Exit For Next iCount maxCount = iCount - 1 ' maxCount is the total number of entries objExcel.ActiveWorkbook.Close objExcel.Quit Options.DefaultHighlightColorIndex = wdTurquoise Selection.HomeKey Unit:=wdStory ' It is not necessary to move the cursor as there is only replacement. With Selection.Find .ClearFormatting .Replacement.ClearFormatting .Replacement.Highlight = True .Replacement.Text = "^&" .Wrap = wdFindStop ' Up to end of document ' Keep settings outside the loop to save steps For iCount = 2 To maxCount .Text = VChar(iCount) .Execute Replace:=wdReplaceAll Next End With ActiveDocument.TrackRevisions = RT End Sub Last edited by hcl75; 10-02-2022 at 07:45 AM. |
Tags |
word macro |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
PowerPoint macro to change words between quotes to italic needed | KarenK13 | PowerPoint | 9 | 01-12-2020 12:59 PM |
![]() |
angiesnow | Word | 2 | 08-12-2018 03:40 AM |
![]() |
BABZ | Word VBA | 1 | 01-09-2017 10:33 PM |
![]() |
thudangky | Word | 13 | 12-12-2013 02:22 AM |
Macro to mark non-coloured/non-highlighted text as hidden | PeterB | Word | 0 | 10-28-2009 07:54 AM |