Greg
Wed Aug 17 21:45:35 CDT 2005
Who said anything about Helmut Weber ;-)
--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
Vince wrote:
> Ah, so it's Helmut Weber's dilemma (he has helped me on many
> occasions).
> Well, I am sure about the human approach to this, which is to break
> open the car's window and get the house key. Later, you could get
> insurance to pay for the window!
>
> Vince
>
> "Greg Maxey" <gmaxey@mvps.OscarRomeoGolf> wrote in message
> news:ueBlxo5oFHA.2580@TK2MSFTNGP09.phx.gbl...
>> Vince,
>>
>> You come along with a suggestion that works and you are "expert" in
>> my eyes. Thanks.
>>
>> Another user and I where discussing using OR in a find text problem.
>> The discussion turned to a very real human situation where the house
>> is locked and the car is locked. A known spare house key is in the
>> car and a known spare car hey is in the house. There are other keys
>> somewhere to be found. Obviously the problem is resolved and the
>> search can end when either a house or car key is found.
>>
>> Cheers
>>
>> Sub HelmutsDilemma()
>> Dim aWord As Range
>> Dim myStr As String
>> For Each aWord In ActiveDocument.Range.Words
>> myStr = aWord
>> If InStrRev(myStr, " ") = Len(myStr) Then
>> myStr = Left(myStr, (Len(myStr) - 1))
>> End If
>> Select Case myStr
>> Case Is = "car", "house"
>> If aWord.Next(Unit:=wdWord, Count:=1) = "keys " Or _
>> aWord.Next(Unit:=wdWord, Count:=1) = "keys" Then
>> With aWord
>> .MoveEnd Unit:=wdWord, Count:=1
>> .Select
>> End With
>> Exit Sub
>> End If
>> Case Else
>> 'Do Nothing
>> End Select
>> Next
>> End Sub
>>
>> --
>> Greg Maxey/Word MVP
>> See:
>>
http://gregmaxey.mvps.org/word_tips.htm
>> For some helpful tips using Word.
>>
>> Vince wrote:
>>> Greg,
>>>
>>> I am no expert but I think when you say "aWord.Next" it moves to the
>>> next character by default. This code works:
>>>
>>> Dim aWord As Range
>>> For Each aWord In ActiveDocument.Range.Words
>>> MsgBox "BEF: " & aWord & " AFT: " & aWord.Next(unit:=wdWord,
>>> Count:=1) Next aWord
>>>
>>> Vince
>>>
>>> "Greg Maxey" <gmaxey@mvps.OscarRomeoGolf> wrote in message
>>> news:uhco734oFHA.3960@TK2MSFTNGP12.phx.gbl...
>>>> In the following code why does the line MsgBox aWord.Next return
>>>> just the first letter of the next word rather than the complete
>>>> word? Thanks Sub Testing()
>>>> Dim aWord
>>>> For Each aWord In ActiveDocument.Range.Words
>>>> MsgBox aWord
>>>> MsgBox aWord.Next
>>>> Next aWord
>>>> End Sub
>>>>
>>>> --
>>>> Greg Maxey/Word MVP
>>>> See:
>>>>
http://gregmaxey.mvps.org/word_tips.htm
>>>> For some helpful tips using Word.