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

Free Support Forum - aspose.com

Hide styles or set recommanded styles

Dear Aspose support team,

I try to create a word document from a word template programmatically quite simple :

byte[] template = System.IO.File.ReadAllBytes(@"Resources\Default_SHS_HY_hoch.dotx");
    
using (MemoryStream mem = new MemoryStream(template))
{
    Aspose.Words.Document doc = new Aspose.Words.Document(mem);
    doc.Save(@"C:\DM_NET\result.docx");      
}

If you open now result.docx,
you will notice recommended built-in styles (Hashtag,common text for example)
in the word document styles pane (recomanded view, not all styles view),
which are not seen in the word template (again select the recomanded view, not all styles view)

My question is,
if i can hide styles, so that they do longer appear in the recommended style view.

Word feature:
To manage your styles list:

  • Press Ctrl+Alt+Shift+S. Word displays the Styles task pane.
  • Click the Manage Styles button. (This button is at bottom of Styles task pane; it looks like the letter A with a check…
  • Make sure the Recommend tab is displayed. (See Figure 2.)
  • Select the style that you are not using.
  • Click on Hide Until Used. The style remains on the list with the…
  • Click OK.

Best Regards
Christoph

@christoph_schroeder01_sap_com,

You can use CleanupOptions to remove duplicate and unused (built-in) styles from Word document. In case the problem still remains, then please ZIP and upload your source template Word DOTX document and Aspose.Words generated DOCX file showing the undesired behavior here for testing. We will then investigate the issue on our end and provide you more information.

Dear Awais,
thanks i tried out the following:

Aspose.Words.CleanupOptions cleanupOptions = new Aspose.Words.CleanupOptions();
cleanupOptions.UnusedLists = true;
cleanupOptions.UnusedStyles = true;
cleanupOptions.UnusedBuiltinStyles = true;

doc.Cleanup(cleanupOptions);
doc.Save(@"C:\DM_NET\result.docx");   

and yes some styles are removed , but unfortunately is see still the styles in the ‘recommended view’,
i do only want to see when 'all styles ’ option is set . See picture:
image.png (41.9 KB)

Here i see the mentioned styles (marked red), but there are not seen in the ‘recommanded view’ of the template, like i would to keep it in the generated document out of the
template.

Regards
Christoph

Files:
Default_SHS_HY_hoch.zip (24.9 KB)

result.docx (29.1 KB)

@christoph_schroeder01_sap_com,

We have logged this problem in our issue tracking system with ID WORDSNET-22526. We will further look into the details of this problem and will keep you updated here on the status of correction. We apologize for your inconvenience.