Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-02-2019, 07:34 AM
poggyton poggyton is offline How to point a macro that highlights from a string of words at the footnotes rather than main doc Windows 10 How to point a macro that highlights from a string of words at the footnotes rather than main doc Office 2016
Novice
How to point a macro that highlights from a string of words at the footnotes rather than main doc
 
Join Date: Oct 2019
Posts: 3
poggyton is on a distinguished road
Default How to point a macro that highlights from a string of words at the footnotes rather than main doc

I came across most of a solution to what I am trying to accomplish in this thread https://www.msofficeforums.com/word-...-document.html



Quote:
Originally Posted by macropod View Post
Hi AtaLoss,

Try something based on:
Code:
Sub HiLightList()
Application.ScreenUpdating = False
Dim StrFnd As String, Rng As Range, i As Long
StrFnd = "dog,cat,pig,horse,man"
For i = 0 To UBound(Split(StrFnd, ","))
  Set Rng = ActiveDocument.Range
  With Rng.Find
    .ClearFormatting
    .Text = Split(StrFnd, ",")(i)
    .Replacement.ClearFormatting
    .Replacement.Highlight = True
    .Replacement.Text = "^&"
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .MatchCase = False
    .MatchWholeWord = True
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = True
    .Execute Replace:=wdReplaceAll
  End With
Next
Set Rng = Nothing
Application.ScreenUpdating = True
End Sub
Note: Because I've set 'MatchAllWordForms = True', a Find for 'cat' or 'man' will also find & highlight 'cats' & 'men'. Apart from that, the matched words must be whole words. That means you don't need multiple expressions to capture the various forms of a given word.
The only problem I'm having is that this only highlights above the line text, not text within footnotes. I would prefer if it it only searched footnotes, but all text could also work. From my brief research I believe this has to do with the range being set, and I've been noodling around with the "Footnotes" object to try to change this with no success.

Thank you,

Poggyton
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to point a macro that highlights from a string of words at the footnotes rather than main doc Looking for certain words in a string Guinness Excel 13 08-09-2019 08:50 AM
Word VBA_find string against bullet point Mahesh Word VBA 2 01-19-2018 03:27 AM
How to point a macro that highlights from a string of words at the footnotes rather than main doc Adding spaces only between each main bullet point dylansmith Word 2 09-02-2015 05:14 AM
Can you align the starting point of footnotes in multi-column format? New Daddy Word 1 11-10-2012 01:54 AM
How to make words hot and point to a web address? jlp Word 2 05-27-2012 01:58 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:25 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