Adding a paragraph

C

Carl

Hi all
I'm running Word97 and I'm trying write code to add a new
paragraph. Some attempts will put the cursor in the first
place of the next paragraph which is not a NEW paragraph.
Other attempts would just move down one line and split the
existing paragraph. My latest will work only if there is
text in the paragraph. Empty paragraphs cause it to move
up (it's the Selection.MoveLeft that does this...)

This is my latest attempt:
Public Sub EndOfPara()

'this sub will move the cursor to the end of the paragraph
then insert another
Selection.EndOf Unit:=wdParagraph
Selection.MoveLeft
Selection.EndKey
Selection.TypeParagraph

End Sub
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Carl > écrivait :
In this message, < Carl > wrote:

|| Hi all
|| I'm running Word97 and I'm trying write code to add a new
|| paragraph. Some attempts will put the cursor in the first
|| place of the next paragraph which is not a NEW paragraph.
|| Other attempts would just move down one line and split the
|| existing paragraph. My latest will work only if there is
|| text in the paragraph. Empty paragraphs cause it to move
|| up (it's the Selection.MoveLeft that does this...)
||

Try not to use the Selection object whenever you can.
It can get messy, as you have just found out!
Range objects are much sturdier and more reliable.

Try this:

'_______________________________________
Dim CurPar As Range

Set CurPar = Selection.Paragraphs(1).Range

CurPar.InsertParagraphAfter
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

Jezebel

This will add a new empty paragraph after the first paragraph of the
selection:

Selection.Paragraphs(1).Range.InsertParagraphAfter
 

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