Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 08-14-2015, 06:27 AM
gmayor's Avatar
gmayor gmayor is offline Create an input box for arrays Windows 7 64bit Create an input box for arrays Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

How about
Code:
Sub FindHighlightWord()
Dim oRng As Word.Range
Dim vWords As Variant
Dim i As Long
Dim strWords As String
    strWords = InputBox(Prompt:="Enter the words to highlight separated by commas", _
                        Title:="Highlight words", _
                        Default:="Friend,MITS,ICMR")

    vWords = Split(strWords, ",")
    For i = 0 To UBound(vWords)
        Set oRng = ActiveDocument.Range
        With oRng.Find
            .ClearFormatting
            .Replacement.ClearFormatting
            Do While .Execute(FindText:=Trim(vWords(i)), _
                              MatchWholeWord:=True) = True
                oRng.HighlightColorIndex = wdBrightGreen
                oRng.Collapse 0
            Loop
        End With
    Next
lbl_Exit:
    Set oRng = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Create an input box for arrays Mail merge from excel - need to create sheets and create a table bluenosebex Mail Merge 5 08-02-2015 05:34 PM
Variable arrays from user input SeattleITguy Excel Programming 1 01-29-2015 09:19 AM
Create an input box for arrays Searching Arrays without Loops? ptmuldoon Word VBA 3 12-13-2014 11:21 AM
Create an input box for arrays Input Box ubns Word 2 04-13-2012 06:28 AM
Create an input box for arrays re-naming arrays in VBA? JDevsFan Excel Programming 4 03-15-2012 08:44 AM

Other Forums: Access Forums

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