I need help with a While loop

R

rachelle34

I need the following while loop to stop at the end of the document.
have tried both the provious helps but neither work. Please help.



endParameter = True
While (endParameter)
If ((Right(Selection.Text, 10) = "Event Date") Or
(Right(Selection.Text, 10) = "EVENT DATE")) Then
endParameter = False
Else
Selection.MoveRight Unit:=wdWord, Count:=1,
Extend:=wdExtend
End I
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

It would be better if you told us what you are trying to do, rather than how
you are trying to do it. That makes it easier for us to give you a solution
that works.

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
 
R

rachelle34

This code is just a small part of a macro designed to reformat email
from my industry. After it finds the section "Event Date", it the
goes on to format it according to a preset design by my customers, bu
that is all in other With statements. The code for the While loop i
not neccessary 'broken', but it does not take into account when 'even
date' is not found and it is at the end of the document. Thank yo
guys for your help. I need some more. See below.

----- Snoopy wrote: -----

You need to check to see if you're at the end of the document i
your Else
statement after you move your selection, and if you're at the en
then you
need to change endParameter to False.

How do you do that? Check to see if its at the end of the document
that is? I have searched everywhere for some kind of Els
If(AtTheEndofDocument) Then endParameter = false

Thank
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

I think you should be using a

Do While .Execute(FindText:=" Event Date", MatchWildcards:=False,
MatchCase: = False, Wrap:=wdFindStop, Forward:=True) = True
<Command>
Loop


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top