Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0
Description

Excerpt

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



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

          //--- 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:vb.net
|title=vb.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)
        
Signature
C#C#
Wiki Markup
{description}
{excerpt}Represents a paragraph in the Word document. Technically, a paragraph is a block of text that ends with a carriage return.{excerpt}
{signature:C#}
 public class Paragraph : Element
Signature
{signature}{signature:vb.net
vb.net
}
Public Class Paragraph
		Inherits Element
Remarks
To create a new paragraph, use
{signature}
{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.
Example
Code Block
csharpcsharp
titleC#
Code Block
vb.nettitle
Properties

...

Name

...

Description

...

Formatting

...

{code}

{example}
{properties}
||Name||Description||
|[Formatting|Paragraph.Formatting]|{excerpt-include:Paragraph.Formatting

...

Style

|nopanel=true}|
|[Style|Paragraph.Style]|{excerpt-include

...

:Paragraph.Style

...

|nopanel=true}|