Removing empty bullet points during Mail Merge


My company has a license for Aspose and we use it in our product. It works very well for us.

The problem I am having at the moment is that bullet points are not getting deleted. After mail merge, any blank merge fields get removed using Aspose. However, If there is a list of bullet points, each with just a merge field in it, I cannot work out how to get rid of the blank bullet points.

I have seen the solution of using IF statements within the template, but this is not doing the trick. I’ve seen your solution for this on another thread, but it does not work for me. See input.docx (attached) for my template. When running my test, merge1 and merge3 are provided, and merge2 is blank. You can see the results in output.doc (also attached).

Can you look at my template and see if I’m doing anything wrong? I am not sure if this is a bug in your code, a bug in my code, or a deficiency of Microsoft Word.

Additional question: Numbered bullet points. I would like to be able to have blank numbered bullet points removed, and the numbering update itself. Is this possible?

Thanks in advance

Hi David,

Thanks for your inquiry. In case you are using an older version of Aspose.Words, I would suggest you please upgrade to the latest version (v13.4.0) from here and let us know how it goes on your side. Please use the following code snippet to remove empty bullets. Hope this helps you. Please let us know if you have any more queries.

Document doc = new Document(MyDir + "input.docx");
doc.MailMerge.Execute(new string[]
    new object[]
        "test 1",
        " Test 3"
foreach(Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true))
    if (para.ParagraphFormat.IsListItem && para.Range.Text.Trim() == "")
doc.Save(MyDir + "out.docx");