Re: Auto Numbering of MSWord Not working

Hi
Thanks for your inquiry. It seems that you did some manipulations with file programmatically. Could you please provide me your code for investigating? After open/save numbering is preserved. Most probably you are using InsertDocument method for inserting this RTF into another document or import nodes from RTF document. After these manipulations numbering will be lost because each member have different parent list. As a workaround you can loop and make list to be same for each list item.
Best regards.

Hi,
Thanks for looking into this issue. Please have a look at the code snippet attached which i am using in my application. I am invoking the function ProcessBodyTag() to process the content available in an Input file. Please let me if you require any additional information.
Thanks
Tony

Hi
Thank you for additional information. The reason of this problem is the same as I described earlier in my previous post. As a resolution you can try using the following code:

private bool InsertBodyContent(Node paleceHolder, Node startNode, ref int nErrorCode, ref string strErrorDesc)
{
    m_oOutDoc = paleceHolder.Document;
    Node currentNode = startNode;
    // Create temporary list
    Aspose.Words.Lists.List srcTmpList = null;
    Aspose.Words.Lists.List dstTmpList = null;
    foreach (Section srcSection in m_oInDoc.Sections)
    {
        // Loop through all block level nodes (paragraphs and tables) in the body of the section.
        foreach (Node srcNode in srcSection.Body)
        {
            // This creates a clone of the node, suitable for insertion into the destination document.
            Node newNode = m_oOutDoc.ImportNode(srcNode, true, ImportFormatMode.KeepSourceFormatting);
            if (srcNode.NodeType == NodeType.Paragraph)
            {
                Paragraph srcTmpPar = (Paragraph)srcNode;
                Paragraph dstTmpPar = (Paragraph)newNode;
                if (srcTmpPar.ListFormat.List == srcTmpList)
                {
                    dstTmpPar.ListFormat.List = dstTmpList;
                }
                else
                {
                    srcTmpList = srcTmpPar.ListFormat.List;
                    dstTmpList = dstTmpPar.ListFormat.List;
                }
            }
            // Insert new node after the reference node.
            paleceHolder.ParentNode.InsertBefore(newNode, paleceHolder);
        }
    }
    paleceHolder.Remove();
    return true;
}

Hope this helps.
Best regards.

Hi
Thanks for your inquiry. There should be one small modification in the method and all should work fine. Please see the following code:

private bool InsertBodyContent(Node paleceHolder, Node startNode, ref int nErrorCode, ref string strErrorDesc)
{
    m_oOutDoc = paleceHolder.Document;
    Node currentNode = startNode;
    // Create temporary list
    Aspose.Words.Lists.List srcTmpList = null;
    Aspose.Words.Lists.List dstTmpList = null;
    foreach (Section srcSection in m_oInDoc.Sections)
    {
        // Loop through all block level nodes (paragraphs and tables) in the body of the section.
        foreach (Node srcNode in srcSection.Body)
        {
            // This creates a clone of the node, suitable for insertion into the destination document.
            Node newNode = m_oOutDoc.ImportNode(srcNode, true, ImportFormatMode.KeepSourceFormatting);
            if (srcNode.NodeType == NodeType.Paragraph)
            {
                Paragraph srcTmpPar = (Paragraph)srcNode;
                if (srcTmpPar.IsListItem)
                {
                    Paragraph dstTmpPar = (Paragraph)newNode;
                    if (srcTmpPar.ListFormat.List == srcTmpList)
                    {
                        dstTmpPar.ListFormat.List = dstTmpList;
                    }
                    else
                    {
                        srcTmpList = srcTmpPar.ListFormat.List;
                        dstTmpList = dstTmpPar.ListFormat.List;
                    }
                }
            }
            // Insert new node after the reference node.
            paleceHolder.ParentNode.InsertBefore(newNode, paleceHolder);
        }
    }
    paleceHolder.Remove();
    return true;
}

Best regards.