End of Doc Check

J

John Edward

Hi,

I am trying to write a macro to remove the blank lines,
ie return key, of a document until the end of the
document. How do I check for the end of the document and
stop the macro with the while loop?

Here is my current code:

loopct = 0
Do While loopct < 5000
If Selection.Characters(1) Like Chr(13) Then
Selection.Delete Unit:=wdCharacter, Count:=1
Else
Selection.MoveDown Unit:=wdLine, Count:=1
End If
loopct = loopct + 1
Loop

Thanks in advance
 
D

Doug Robbins - Word MVP

You don't really need a macro, but you could record doing an Edit Replace
where you search of ^p^p and replace it with ^p or if there a multiple
carriage returns in a row, a Wildcard replace searching for ^13{1,} and
replacing it with ^p

See the article “Finding and replacing characters using wildcards” at:

http://word.mvps.org/FAQs/General/UsingWildcards.htm


--
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
 
J

John Edward

How Doug,

How about page break, what is the code for page break, I
would also like to do the same for page break - delete
all the page break.

Thanks
 
D

Doug Robbins - Word MVP

^m

Click on the More button in the Edit>Find dialog and then click on Special
and you can select the ones that you are interested in and the code for them
will be entered into the Find what control of the dialog.

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