We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Numbering in word document

Hi,

I am trying to access numbering in a word document and so far I have been unable to access them. I want to change the Font of every numbering in a document.

I have tried something like:

for (i = 0; i < doc.Lists.Count; i++)
{
MessageBox.Show(doc.Lists[i].Style.Font.Name);
}

but this gives null exception. A sample document is attached for which I would like to change the font of the numbered list.

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

Thanks for your inquiry. You can try using the following code to achieve what you need.

Document doc = new Document(@"Test206\in.doc");

//Get collection of Paragraphs from the document

NodeCollection pars = doc.GetChildNodes(NodeType.Paragraph, true);

//Loop thiought all paragraphs and check whether this is list item

foreach (Paragraph par in pars)

{

if (par.IsListItem)

{

//Change paragraph break font

//This will also change font of list numbers

par.ParagraphBreakFont.Color = Color.Red;

par.ParagraphBreakFont.Size = 16;

}

}

//Save output doc

doc.Save(@"Test206\out.doc");

Hope this helps.

Best regards.

I just tried your code and it does not work. While it makes all the other parts of the cell to the font it specified, the numbered font is still the same. I used the code:

if (par.IsListItem)
{
//Change paragraph break font
//This will also change font of list numbers
par.ParagraphBreakFont.Name = “NikoshBAN”;
}

but the font still remains “SulekhaT” instead of NikoshBAN as specified in the code.

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

Thanks for your request. Try also changing font of ListLevel. See the following code:

if (par.IsListItem)

{

//Change paragraph break font

//This will also change font of list numbers

par.ParagraphBreakFont.Name = "NikoshBAN";

par.ListFormat.ListLevel.Font.Name = "NikoshBAN";

}

Best regards.

Thanksssss! It worked!!!