Free Support Forum - aspose.com

Adding to a MS Word doc

I'm a bit new to Aspose Words model but have been able to create a document from scratch. However this time I need to open an existing MS Word document and add text to the various cells. The code that I'm using is

Dim doc As Aspose.Words.Document = New Aspose.Words.Document("BioSketch_Page1.doc")
Dim builder As DocumentBuilder = New DocumentBuilder(doc)

builder.MoveToCell(0, 3, 1, 0)
builder.Font.Size = 10
builder.Font.Bold = False
builder.Font.Color = System.Drawing.Color.Blue
builder.Font.Name = "Arial"
builder.Underline = Underline.None
builder.Write("Write Some Text")
doc.Save("tmp.doc")
Process.Start("tmp.doc")

Using this code I don't get anything on the document and if I change to another cell I get an error, which kind of tells me I'm not identifing the object properly. I've attached the document so any help is deeply apprecieated.

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. The problem occurs because you try writing text into the vertically merged cell. When few cells are vertically merged, text of the first cell in the merged region only is displayed. So in your case, you should just write text in the previous row:

Document doc = new Document(@"Test001\BioSketch_Page1.doc");

DocumentBuilder builder = new DocumentBuilder(doc);

builder.MoveToCell(0, 2, 1, 0);

builder.Font.Size = 10;

builder.Font.Bold = false;

builder.Font.Color = Color.Blue;

builder.Font.Name = "Arial";

builder.Underline = Underline.None;

builder.Write("Write Some Text");

doc.Save(@"Test001\tmp.doc");

Best regards.

Thanks for the ultra fast reply