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

Free Support Forum - aspose.com

Reset list numbering value

Hello, I need to reset the start value of a list with a custom style of “ACT Defined Term Number”.

Attached is a sample document SampleNumbering.docx.

For example, I would like the numbering to restart with (a) under the paragraph starting with “Customer Cause”. I’ve looked over the forum and don’t see a good solution to this.

I am using Aspose.Words.for.Java version 14.12.0 and DocumentBuilder to create the document.

Any help is appreciated. Thanks.

Hi Linda,

Thanks for your inquiry. If you need to reset numbering in list you should reset list itself. Please try using the following code for example:
Document doc = new Document(getMyDir() + “SampleNumbering.docx”);

com.aspose.words.List listCopy = null;
for (Paragraph para : (Iterable<Paragraph>)doc.getChildNodes(NodeType.PARAGRAPH, true))
if (para.isListItem())
if (para.toString(SaveFormat.TEXT).startsWith("any improper use, misuse "))
listCopy = doc.getLists().addCopy(para.getListFormat().getList());

    <font color="RED"><b>if</b></font> <font color="BLUE"><b>(</b></font>listCopy <font color="BLUE">!</font><font color="BLUE">=</font> <font color="RED"><b>null</b></font><font color="BLUE"><b>)</b></font>
        para<font color="BLUE"><b>.</b></font>getListFormat<font color="BLUE"><b>(</b></font><font color="BLUE"><b>)</b></font><font color="BLUE"><b>.</b></font>setList<font color="BLUE"><b>(</b></font>listCopy<font color="BLUE"><b>)</b></font><font color="BLUE"><b>;</b></font>
<font color="BLUE"><b>}</b></font>


doc.save(getMyDir() + “15.8.0.docx”);

I hope, this helps.

Best regards,

The list copy does not seem to work reliably for me. I can get the first paragraph to start at (a) but then the following paras just pick up with the old list values. such as (a) followed by (e).

When I open the Word document and manually right click --> Restart at 1, the only change I see to the underlying document is this where the number property with <w:ilvl w:val=“0”> is added. I opened up the numbering.xml and there were not multiple copies of the ACTDefinedTermNumber list like there are when I try to copy the list.

Is there any way to set this <w:ilvl w:val="0’> via Aspose DocumentBuilder?

<w:p w:rsidR=“00BE03F3” w:rsidRPr=“00BE03F3” w:rsidRDefault=“00BE03F3” w:rsidP=“00E83BB5”>
<w:pStyle w:val=“ACTDefinedTermNumber”/>
<w:ilvl w:val=“0”/>
<w:numId w:val=“38”/>
<w:t>correction of a Fa</w:t>
<w:t xml:space=“preserve”>ult; or </w:t>

Hi Linda,

Thanks for your inquiry. Please attach your input Word document and corresponding expected Word document here for our reference. We will investigate the issue on our end and provide you more information.

Best regards,

The SampleNumbering.docx is a sample of the current output. I have attached SampleNumbering_fixed.docx as the desired output. Searching for exact text as shown in the code example above is not a good option. I need to be able to restart (same as ‘Restart at a’) the list numbering at each para with a style of “ACT Defined Term Para”, after the initial list has started.

Hi Linda,

Thanks for your inquiry. Please try using the following code. It assigns a new List to all list paragraphs with style ‘ACT Defined Term Number’ under specific paragraphs with style ‘ACT Defined Term Para’.
Document doc = new Document(getMyDir() + “SampleNumbering.docx”);

com.aspose.words.List listCopy = null;
for (Paragraph para : (Iterable<Paragraph>)doc.getChildNodes(NodeType.PARAGRAPH, true)) {
if (para.getParagraphFormat().getStyleName().equals(“ACT Defined Term Para”)) {
listCopy = doc.getLists().addCopy(doc.getLists().get(0));
if (para.getParagraphFormat().getStyleName().equals(“ACT Defined Term Number”)) {
if (listCopy != null)

doc.save(getMyDir() + “15.10.0.docx”);

Hope, this helps.

Best regards,

Your last reply got me most of the way there. I needed to determine which list to copy since there are multiple lists in my document. The following method worked out very well for me.
private void resetListStart(Document doc) throws Exception {

com.aspose.words.List listCopyDefTermNumber = null;
com.aspose.words.List definedTermNumberList = doc.getStyles().get(“ACT Defined Term Number”).getListFormat().getList();
logger.debug("definedTermNumberList id: " + definedTermNumberList.getListId() + ", style = " + definedTermNumberList.getStyle());

com.aspose.words.List listCopyPart = null;
com.aspose.words.List partList = doc.getStyles().get(“ACT Part”).getListFormat().getList();
logger.debug("partList id: " + partList.getListId() + ", style = " + partList.getStyle());

for (Paragraph para : (Iterable)doc.getChildNodes(NodeType.PARAGRAPH, true)) {
if (para.getParagraphFormat().getStyleName().equals(“ACT Defined Term Para”)) {
listCopyDefTermNumber = doc.getLists().addCopy(definedTermNumberList);
} else if (para.getParagraphFormat().getStyleName().equals(“ACT Defined Term Number”)) {
if (listCopyDefTermNumber != null)
} else if (para.getParagraphFormat().getStyleName().equals(“ACT Schedule”)) {
listCopyPart = doc.getLists().addCopy(partList);
} else if (para.getParagraphFormat().getStyleName().equals(“ACT Part”)) {
if (listCopyPart != null)


Thanks again for the help!


It is great you were able to find what you were looking for. Please let us know any time you have any further queries.

Best regards,