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}{signature:
}
Signature
vb.net
vb.net
Public Class Paragraph
		Inherits Element
{signature}
{remarks}To create a new paragraph, use [
Remarks

To create a new paragraph, use Element.InsertParagraphBefore()

|Element.InsertParagraphBefore]

or

[

Element.InsertParagraphAfter()

|Element

.

InsertParagraphAfter].

Each

of

these

methods

take

a

single

argument

of

type

[

NamedStyle

|NamedStyle]

.

This

argument

can

be

null.

If

it

is

null,

the

Normal

style

is

used.

This

method

can

be

called

from

the

[

Document

|Document]

object

because

{{

Document

}}

inherits

from

the

[

Element

|Element]

class.

{remarks} {example}{code:csharp|title=C#}

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} {code:
Code Block
vb.net
|title=
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)
        
{code} {example} {properties} ||Name||Description|| |[Formatting|Paragraph.Formatting]|{excerpt-include:Paragraph.Formatting|nopanel=true}| |[Style|Paragraph.Style]|{excerpt-include:Paragraph.Style|nopanel=true}|
Properties

Name

Description

Formatting

Excerpt Include
Paragraph.Formatting
Paragraph.Formatting
nopaneltrue

Style

Excerpt Include
Paragraph.Style
Paragraph.Style
nopaneltrue