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
[email protected]
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
 
Top