Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Selecting Multiple Words

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sos00 - 02 Jan 2006 06:43 GMT
Hi,

is it possible to select multiple words in a word document at once ?
for example i want to select and highlight "word1" and "word2" in this text

word0 word1 word
word word2 word3

Thanks
Cindy M  -WordMVP- - 02 Jan 2006 07:44 GMT
Hi Sos00,

> is it possible to select multiple words in a word document at once ?
> for example i want to select and highlight "word1" and "word2" in this text
> :
>  
> word0 word1 word
> word word2 word3

In word 2002 and 2003, in the user interface, yes: select the first word, then
hold Ctrl and select the next, and so on.

This functionality is NOT available through the Word object model (VBA),
however. The only part of this functionality supported in the object model is
selecting all text that's formatted the same as the current selection:

   WordBasic.SelectSimilarFormatting

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)
sos00 - 02 Jan 2006 08:20 GMT
Thanks,
is it possible to use Find to do this ?
is Find capable to find multiple words at once ?

> Hi Sos00,
>
[quoted text clipped - 23 lines]
> This reply is posted in the Newsgroup; please post any follow question or
> reply in the newsgroup and not by e-mail :-)
Helmut Weber - 02 Jan 2006 10:21 GMT
Hi,

you may create your own find and highlight code.
Still, all find action is serial, in a way, as there is
no straightforward search doing all at once.

Have a look at this simple example:

Sub MyFind()
Dim l As Long
Dim rDcm As Range
Dim sTmp() As String
sTmp = Split(InputBox("Myfind"), " ")

For l = 0 To UBound(sTmp)
  Set rDcm = ActiveDocument.Range
  With rDcm.Find
     .Text = sTmp(l)
     While .Execute
        rDcm.HighlightColorIndex = wdYellow
     Wend
  End With
Next
End Sub

Note that the delimiter is " ".

You may add all kinds of features you can think of.

In the inputbox, type something like: "brown fox jumps",
without the quotation marks.

Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
Cindy M  -WordMVP- - 02 Jan 2006 11:16 GMT
Hi Sos00,

> is it possible to use Find to do this ?
> is Find capable to find multiple words at once ?

Not if they're not contiguous. Again, the user interface
supports this, but the object model does not.

The way you have things lined up in your original
question... Could this be in a table? You can select a
table column.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:-)
sos00 - 03 Jan 2006 06:18 GMT
Thanks...

> You can select a table column.

you mean selecting multiple columns or rows in a table ?

> Hi Sos00,
>
[quoted text clipped - 17 lines]
> follow question or reply in the newsgroup and not by e-mail
> :-)
Doug Robbins - Word MVP - 03 Jan 2006 10:26 GMT
In your original post, the assumption was that Word1 and Word2 might be in
cells in the same column in a table.

You can select multiple contiguous rows or columns in a table, but there is
no way using vba to select anything that is NOT contiguous.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Thanks...
>
[quoted text clipped - 23 lines]
>> follow question or reply in the newsgroup and not by e-mail
>> :-)
Doug Robbins - Word MVP - 02 Jan 2006 07:48 GMT
Hold down the control key as you select the second and any subsequent words.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Hi,
>
[quoted text clipped - 6 lines]
>
> Thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.