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.

get thew word number

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
filo666 - 13 Feb 2008 13:28 GMT
Hi, I want to accomplish 2 thinks:

1) something like wordpossition=Activedocument.selection.words.possition
(and the possition of the word in the document is obtained)
of course the command is incorrect.

2) an if structure:

If the selected word is "-" and one word or character before the selected
word is a letter or a number (just letter or number, not "/" or "." or
anything) and one character after the selected word is " " then
..........................
end if

Thanks for your help
Greg Maxey - 13 Feb 2008 13:57 GMT
Something like this:

Sub Scratchmacro()
Dim oWord As Range
Dim oRng As Range
Set oRng = ActiveDocument.Range
Set oWord = Selection.Words(1)
oRng.End = oWord.End
MsgBox oRng.Words.Count
If oWord.Text = "- " Then
 If oWord.Characters.First.Previous Like "[A-Za-z0-9]" Then
   MsgBox "Bingo"
 End If
End If
End Sub

Signature

~~~~~~~~~~~~~~~~~~~~~~~~~~~
Greg Maxey -  Word MVP

My web site http://gregmaxey.mvps.org
Word MVP web site http://word.mvps.org
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> Hi, I want to accomplish 2 thinks:
>
[quoted text clipped - 12 lines]
>
> Thanks for your help
Klaus Linke - 14 Feb 2008 07:21 GMT
See also the reply to the message you've posted elsewhere.

Klaus
 
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.