Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin
Description

Excerpt

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

Signature
C#
C#
 public class Paragraph : Element
Signature
vb.net
vb.net
Public Class Paragraph
		Inherits Element
Remarks

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.

Example
Code Block
csharp
csharp
titleC#

          //--- 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];
        
Code Block
vb.net
vb.net
titlevb.net

          '--- 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)
        
Properties

Name

Description

Formatting

Excerpt Include
Paragraph.Formatting
Paragraph.Formatting
nopaneltrue

Style

Excerpt Include
Paragraph.Style
Paragraph.Style
nopaneltrue