Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Closed Thread
 
Thread Tools Display Modes
  #1  
Old 09-22-2018, 11:37 PM
sknanda sknanda is offline multi words selection in ms word Windows 7 32bit multi words selection in ms word Office 2010 32bit
Novice
multi words selection in ms word
 
Join Date: Sep 2018
Posts: 15
sknanda is on a distinguished road
Default 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  
Old 09-23-2018, 12:18 AM
Guessed's Avatar
Guessed Guessed is online now multi words selection in ms word Windows 10 multi words selection in ms word Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,967
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Are we supposed to guess where the macro is that you found?
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
  #3  
Old 09-23-2018, 12:33 AM
sknanda sknanda is offline multi words selection in ms word Windows 7 32bit multi words selection in ms word Office 2010 32bit
Novice
multi words selection in ms word
 
Join Date: Sep 2018
Posts: 15
sknanda is on a distinguished road
Default

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  
Old 09-23-2018, 04:24 AM
Guessed's Avatar
Guessed Guessed is online now multi words selection in ms word Windows 10 multi words selection in ms word Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,967
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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  
Old 09-23-2018, 04:26 AM
macropod's Avatar
macropod macropod is offline multi words selection in ms word Windows 7 64bit multi words selection in ms word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

StrFnd = InputBox("Please input the required search terms, separated by commas (e.g.dog,cat,mouse)")
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
  #6  
Old 09-24-2018, 09:36 PM
sknanda sknanda is offline multi words selection in ms word Windows 7 32bit multi words selection in ms word Office 2010 32bit
Novice
multi words selection in ms word
 
Join Date: Sep 2018
Posts: 15
sknanda is on a distinguished road
Default

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  
Old 09-26-2018, 10:36 PM
sknanda sknanda is offline multi words selection in ms word Windows 7 32bit multi words selection in ms word Office 2010 32bit
Novice
multi words selection in ms word
 
Join Date: Sep 2018
Posts: 15
sknanda is on a distinguished road
Default 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  
Old 09-27-2018, 12:50 AM
Guessed's Avatar
Guessed Guessed is online now multi words selection in ms word Windows 10 multi words selection in ms word Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,967
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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  
Old 09-27-2018, 05:15 AM
sknanda sknanda is offline multi words selection in ms word Windows 7 32bit multi words selection in ms word Office 2010 32bit
Novice
multi words selection in ms word
 
Join Date: Sep 2018
Posts: 15
sknanda is on a distinguished road
Default

Thank you very much. Pls suggest some good book for me to learn. Thank you.
  #10  
Old 09-27-2018, 03:13 PM
macropod's Avatar
macropod macropod is offline multi words selection in ms word Windows 7 64bit multi words selection in ms word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Closed Thread

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
multi words selection in ms word Attempting to find text, select words before it, and format the entire selection KeviM Word VBA 1 04-07-2017 05:36 PM
multi words selection in ms word 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
multi words selection in ms word 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

Other Forums: Access Forums

All times are GMT -7. The time now is 11:23 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft