#1
|
|||
|
|||
multi words selection in ms word
Sir, I came across a macro that searches for different words viz "xxx,yy,aaaa,qqqqqqq,pppppppp" all in one go. This is what I wanted for long. But to take full advantage of this macro I need to be able to input the list of words from console so that I do not have to edit the macro for each search. Will you please modify it to accept input from keyboard. At present I only need to highlight all words and make no changes. Only want to read. Regards Last edited by macropod; 09-23-2018 at 04:24 AM. Reason: Delete email address for privacy |
#2
|
||||
|
||||
Are we supposed to guess where the macro is that you found?
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
Sir, I thank you for your quick response. This was my first post on this forum. I give below what I can. This is the macro:
--------------------- 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 It was from "macropod Administrator" dated 5-18-2011. I hope it helps you. I do not know how to refer to this URL. I tried it by editing macro by replacing find list. IT WORKS!! Now I need to input my search list "dog,cat,pig,horse,man" from keyboard. Please help. Regards. Last edited by macropod; 09-24-2018 at 10:20 PM. Reason: Added code tags & formatting |
#4
|
||||
|
||||
You can replace the following line
StrFnd = "dog,cat,pig,horse,man" with something along the lines of StrFnd = InputBox("Type words separated by a comma","Title of box","dog,cat,pig,horse,man")
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#5
|
||||
|
||||
StrFnd = InputBox("Please input the required search terms, separated by commas (e.g.dog,cat,mouse)")
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#6
|
|||
|
|||
Sir, I am grateful for help on macro for highlighting multi-words in word document. Will you now please modify that macro (or write a new one for me) to list display searched words in a block of say 100 words (changeable parameter)after one word from list has been located. For example : search for: "actor,red,house, London" TO GIVE result as: house.....red......London..............actor (in say "n" consecutive words in a paragraph Or even better in a sentence. Thank you
|
#7
|
|||
|
|||
needed macro to select words within given next n words
I am using a macro on which I got help on this Forum. This macro lists in one go all (those present) words being searched and highlighting them. Will someone please help me with a macro which does this:
Say we search for words aaa,ssss,ppppp,wwwww in a word document. All may not be actually present in the document. If, say, occurrence of any one of these is encountered then the macro should go into some loop and try to find if all the remaining or some are also present in the next n words starting with that found. This n shall be a variable the user can set value like 40,90,100. |
#8
|
||||
|
||||
The point of assignments is that you do them yourself so you can LEARN. Whilst your ingenuity is admirable it circumvents the point of the assignment.
Make a real attempt and see what you can come up with that makes use of Range.MoveEnd
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#9
|
|||
|
|||
Thank you very much. Pls suggest some good book for me to learn. Thank you.
|
#10
|
||||
|
||||
Doubtless, whoever is running your course has provided a reading list.
And, had I known your previous thread was trying to get us to do your homework for you, I'd have told you to do away and do some learning. Having us do your homework teaches you little more than how to cheat... Kindly don't start multiple threads on the same topic. Threads merged and closed.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Report Containing Multi-Selection Dropdown | Donnatoye | Word VBA | 10 | 06-20-2018 08:58 AM |
Attempting to find text, select words before it, and format the entire selection | KeviM | Word VBA | 1 | 04-07-2017 05:36 PM |
How do I add selection of multi line content control list to specific table cell | Dudlee | Word VBA | 1 | 09-20-2016 04:58 PM |
Selection of all Text for a specific page in word is spanning selection across pages | ramsgarla | Word VBA | 9 | 12-05-2012 03:23 AM |
Ho to perform multi selection in drop down lists? | nashville | Word | 0 | 09-29-2010 07:10 AM |