Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-01-2022, 07:40 PM
hcl75 hcl75 is offline How to use Word Macro to change all highlighted words as mark-up? Windows 10 How to use Word Macro to change all highlighted words as mark-up? Office 2019
Novice
How to use Word Macro to change all highlighted words as mark-up?
 
Join Date: Oct 2022
Posts: 1
hcl75 is on a distinguished road
Post How to use Word Macro to change all highlighted words as mark-up?


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



Similar Threads
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
How to use Word Macro to change all highlighted words as mark-up? Is this even possible: extrapolating highlighted words angiesnow Word 2 08-12-2018 03:40 AM
How to use Word Macro to change all highlighted words as mark-up? Macro in Word to track colour of highlighted text BABZ Word VBA 1 01-09-2017 10:33 PM
How to use Word Macro to change all highlighted words as mark-up? How to mark underlined words in a sentence as A, B, C, D (beneath the words) 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

Other Forums: Access Forums

All times are GMT -7. The time now is 12:26 PM.


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