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

Free Support Forum - aspose.com

Cannot clear tabstops for a Style

Here is sample code:

doc = New Document("C:\tabstop.dot")
bldr = New DocumentBuilder(doc)
With doc.Styles("Re Line").ParagraphFormat
End With

When I open the resulting document, Style “Re Line” still has a tabstop at .75

Thanks for your request. I managed to reproduce the problem and created new issue #6566 in our defect database. I will notify you as soon as it is fixed.
Best regards.

Any new news on this?


Thanks for your request. Unfortunately, the issue is still unresolved. You will be notified as soon as it is fixed.

Best regards,

Hi Steve,

Hope you are still interested in resolution of this issue. Actually here is no bug in Aspose.Words. Tab stops can be defined in:

  • Paragraphs. You can access them using Paragraph.ParagraphFormat.TabStops.
  • Paragraph styles. You can access then using Style.ParagraphFormat.TabStops.
  • ListLevel. There is no way to access ListLevel’s TabStop itself, but you can get its position. Use ListLevel.TabPosition property.
  • Document. Finally, default TabStop can be specified on Document level. See Document.DefaultTabStop.

TabStopCollection provides method Clear(), which removes all TabStops form the collection. However, sometimes if call for example paragraph.ParagraphFormat.TabStops.Clear(); in the output document you will still see one TabStop. This is not a bug, this occurs because MS Word shows all TabStops of paragraph, i.e. TabStops from Paragraph, Style and ListLevel (if paragraph is list item). So in order to remove all TabStops of a particular paragraph you should use code like the following:

/// Method clears all TabStops asociated with the paragraph.
private static void ClearAllTabStops(Paragraph paragraph)
    // TabStops of paragraph can be defined in three places:
    // 1 - In Paragraph itself, we can access them using ParagraphFormat.
    // 2 - In the Style asociated with the paragraph.
    // 3 - If paragraph is list item, then TabPosition is TabStop of the paragraph.
    // Clear paragraph's TabStops.
    // Clear TabStops from paragraph's style.
    Style paragraphStyle = paragraph.ParagraphFormat.Style;
    // Finaly clear TabPosition if the paragraph is list item.
    if (paragraph.IsListItem)
        paragraph.ParagraphFormat.TabStops.Add(paragraph.ListFormat.ListLevel.TabPosition, TabAlignment.Clear, TabLeader.None);

In your case, you need to clear all TabStops of a style. So your code will look like the following.

Document doc = new Document(@"Test001\Tabstop.dot");
Style relineStyle = doc.Styles["Re Line"];
if (relineStyle.ListFormat != null)
    relineStyle.ParagraphFormat.TabStops.Add(relineStyle.ListFormat.ListLevel.TabPosition, TabAlignment.Clear, TabLeader.None);

Please let me know in case of any issues, I will be glad to help you.
Best regards.