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 / February 2008

Tip: Looking for answers? Try searching our database.

Determining the word possition

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
filo666 - 13 Feb 2008 12:29 GMT
Hello, I would like to:

1) Detemine the word number or possition (something like
wrd=activedocument.selection.words.possition) but of course it does not work.

2) to program this:

If the selected word is "-" and one word before the selected word is a
letter or a number (just a letter or a number) and one word after the
selected word is a space(" ") then ..........

thanks for your help.
Klaus Linke - 13 Feb 2008 18:28 GMT
Hi,

Sounds like a wildcard search would be simpler for what you're trying to do:
Edit > Find, Check "Match wildcards",
Find what: <[a-zA-Z0-9]\-^32

Likely you can achieve whatever you want to do next with a replacement, or
take it from there.

re 1):
What do you mean with "position"... a Range? The character count from the
beginning of the range up to that word? The word count?
It could be something as simple as Selection.Words(1).Start ... or look at
http://word.mvps.org/FAQs/MacrosVBA/GetIndexNoOfPara.htm

re 2):
You could look at "Like" in the VBA help.
The word preceeding the one you have selected would be
Selection.Words(1).Previous.Words(1)

But as suggested above, you might take a step back and describe what your
text looks like and what you want to achieve. Dealing with "words" in the
Word object model would probably be the slowest and most cumbersome way to
go about it.

> one word after the selected word is a space(" ")

A space is never regarded as a word by itself... Spaces belong to the word
preceeding it.

Regards,
Klaus

> Hello, I would like to:
>
[quoted text clipped - 9 lines]
>
> thanks for your help.
 
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.