Close





 
Thursday, 16 December 2010 06:35

How to Edit a Word Document

If you want to edit an existing word document, you should open it first. So, you need to know How to Open a Word Document at first.
To edit a paragraph, you need to reference a Spire.Doc.Documents.Paragraph object which represents the physical paragraph which you want to edit. In this demo, I will edit the second pragraph of the first section of my word document, we suppose I have opened it and reference it via variable document.
[C#]
Section section = document.Sections[0];
Paragraph paragraph = section.Paragraphs[1];
          
[Visual Basic]
Dim section As Section = document.Sections(0)
Dim paragraph As Paragraph = section.Paragraphs(1)
          
Now, we can edit it as we want.
[C#]
//update the original text
paragraph.Text = "Updated";

 //append a new text
paragraph.AppendText(" by Spire.Doc.");
          
[Visual Basic]
'update the original text
paragraph.Text = "Updated"

 'append a new text
paragraph.AppendText(" by Spire.Doc.")
          

Full example

[C#]
//open the word document
Document document = new Document("Editing.doc");

 //get the paragraph which we want to edit
Section section = document.Sections[0];
Paragraph paragraph = section.Paragraphs[1];

 //update the original text
paragraph.Text = "Updated";

 //append a new text
paragraph.AppendText(" by Spire.Doc.");

 //save to a file
document.SaveToFile("Sample.doc");
          
[Visual Basic]
'open the word document
Dim document As New Document("Editing.doc")

 'get the paragraph which we want to edit
Dim section As Section = document.Sections(0)
Dim paragraph As Paragraph = section.Paragraphs(1)

 'update the original text
paragraph.Text = "Updated"

 'append a new text
paragraph.AppendText(" by Spire.Doc.")

 'save to a file
document.SaveToFile("Sample.doc")
          
Published in Program Guide
Wednesday, 21 July 2010 06:49

Word Editing for C#, VB.NET

 

The sample demonstrates how to edit a Word document.

Published in Quick guide
Saturday, 03 July 2010 00:40

EXCEL Edit Chart Sheet for C#, VB.NET

 

The sample demonstrates how to edit chart worksheet in an excel workbook.

EditChart.gif

Published in Charts
Friday, 02 July 2010 14:01

EXCEL Edit Sheet for C#, VB.NET

 

The sample demonstrates how to edit a worksheet in an excel workbook.

EditSheet.gif

Published in Quick guide