Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #11  
Old 07-07-2020, 07:59 PM
MyUserName123 MyUserName123 is offline Macro to Mark Text with Index Codes Windows 10 Macro to Mark Text with Index Codes Office 2019
Novice
Macro to Mark Text with Index Codes
 
Join Date: Jul 2020
Posts: 10
MyUserName123 is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
The easiest fix for the code is to temporarily hide the field codes while the macro is running.
Code:
Sub MarkIndexMacro()
  Dim myRange As Range, aFld As Field, sXE As String
  ActiveWindow.View.ShowHiddenText = False
    Set myRange = ActiveDocument.Range
    With myRange.Find
      .Font.Color = wdColorRed
      Do While .Execute
        sXE = Trim(myRange.Text)
        ActiveDocument.Indexes.MarkEntry Range:=myRange, Entry:=sXE
        myRange.Collapse Direction:=wdCollapseEnd
      Loop
    End With
  ActiveWindow.View.ShowHiddenText = True
End Sub

Hi, I tried your code with a couple of different files and it works great. Thank you for all your help.
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to Mark Text with Index Codes Macro for mark index entry for every word in a document? Jay Jay Word VBA 5 08-13-2015 03:44 PM
Hyperlinking from the Index to the Origin Mark Phil H Word 2 08-30-2013 04:03 AM
Index Addition Leaves Hidden Codes On SQLUSA Word 3 07-23-2012 02:58 AM
Options of Index Mark Entry smaria Word 1 04-22-2010 05:48 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:16 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