Forums     Knowledge Base     OfficeWriter Online     
 
 
This documentation is for
OfficeWriter v3.8.1
.NET Platform

View Docs for Another
Version or Platform

Programmer's Reference > WordApplication API > Paragraph

The Paragraph Object

     extends Element



Represents a paragraph in the Word document. Technically, a paragraph is a block of text that ends with a carriage return.

To create a new paragraph, use Element.InsertParagraphBefore() or Element.InsertParagraphAfter(). Each of these methods take a single argument of type NamedStyle. This argument can be null. If it is null, the Normal style is used. This method can be called from the Document object because Document inherits from the Element class.



Examples:

[csharp]
// Insert a paragraph at the end of a new document and add some sample text
WordApplication app = new WordApplication();
Document doc = app.Create();
Paragraph paragraph = doc.InsertParagraphAfter(null);
paragraph.InsertTextAfter("This is a new paragraph.");

// Get the first paragraph of an existing document
WordApplication app = new WordApplication();
Document doc = app.Open(@"C:\sample.doc");
Paragraph firstParagraph = doc.Elements(Element.Type.Paragraph)[0];
[vbnet]
' Insert a paragraph at the end of a new document and add some sample text
Dim app As New WordApplication()
Dim doc As Document = app.Create()
Dim parargraph As Paragraph = doc.InsertParagraphAfter(Nothing)
paragraph.InsertTextAfter("This is a new paragraph.")

' Get the first paragraph of an existing document
Dim app As New WordApplication()
Dim doc As Document = app.Open("C:\sample.doc")
Dim blocks() As BlockElements = doc.BlockElements
Dim firstParagraph As Paragraph = doc.Elements(Element.Type.Paragraph)(0)


Please note that this object inherits methods and properties not shown here from the following objects:

Paragraph Properties

Property Type Access Description
Formatting ParagraphFormatting read
write

Sets or returns a ParagraphFormatting object that represents the formatting for this paragraph (positioning, line spacing, etc)

Style NamedStyle read
write

Returns or sets an NamedStyle object that represents the Style of this paragraph



This object does not have any methods defined.



Copyright 2007 © SoftArtisans, Inc. All Rights Reserved.