none
how can i distinguish the multi-level heading? RRS feed

  • Question

  • i want to find all of the multi-level heading in the document, but it is difficult for me to finding the diff between some headings. 

    look the below picture, the heading 1("Head1_M") has applyed multi-level style, and the heading 2("head2") has set to none.

    i want to get heading 1 but exclude the heading 2, how can i do it?


    develop use word2010.  thanks.

    Friday, April 25, 2014 10:06 AM

Answers

  • Hi sendreams

    Mmm, the logic used to build the document is a bit... odd. If you select a numbering style linked to Word's built-in Heading styles, then it's best to NOT manually unlink the style from the numbering, such as you show on the right of your screen shot. Typically, one would set up a separate style that looks like Heading 2, but isn't.

    OR one would change the numbering style definition to not use any number for level Heading 2.

    In any case, the

       Range.ListFormat.CountNumberedItems

    property will return 0 if no numbering is set for the paragraph(s) in the Range.


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by sendreams Saturday, April 26, 2014 4:57 AM
    Friday, April 25, 2014 3:54 PM
    Moderator

All replies

  • in currently, my algorithm is using ListString, the code is:

    string listString = headingRng.ListFormat.ListString;
    IsMultiLevel = (listString != null && listString.Trim().Length > 0);

    this code can work for some document, but i don't know does it can working for all situlation.

    please.

    thanks

    Friday, April 25, 2014 10:15 AM
  • Hi sendreams

    Mmm, the logic used to build the document is a bit... odd. If you select a numbering style linked to Word's built-in Heading styles, then it's best to NOT manually unlink the style from the numbering, such as you show on the right of your screen shot. Typically, one would set up a separate style that looks like Heading 2, but isn't.

    OR one would change the numbering style definition to not use any number for level Heading 2.

    In any case, the

       Range.ListFormat.CountNumberedItems

    property will return 0 if no numbering is set for the paragraph(s) in the Range.


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by sendreams Saturday, April 26, 2014 4:57 AM
    Friday, April 25, 2014 3:54 PM
    Moderator
  • hi, Cindy

    thank you very much

    e, i don't want to build a document use this special logic, but because a lot of existed document has apply such style,,, i want to normalize the document style, so should handling many unexpected situlation.

    thanks again.

    • Marked as answer by sendreams Saturday, April 26, 2014 5:09 AM
    • Unmarked as answer by sendreams Saturday, April 26, 2014 5:09 AM
    Saturday, April 26, 2014 4:57 AM
  • hi, Cindy

    on second thoughts,the "Range.ListFormat.CountNumberedItems" property is not enough to distinguish the multi-level style. i think it should work with any other property. isn't it?

    Saturday, April 26, 2014 5:12 AM
  • I don't understand your question...

    Cindy Meister, VSTO/Word MVP, my blog

    Saturday, April 26, 2014 3:28 PM
    Moderator
  • e, i don't want to build a document use this special logic, but because a lot of existed document has apply such style,,, i want to normalize the document style, so should handling many unexpected situlation.


               

    If you are saying that you are trying to fix the formatting in a document that someone else has created, you'll find that this is a manual task...

    Before you start, make a printout of the original document for reference, and then clear all formatting and start fresh.


    Stefan Blom, Microsoft Word MVP

    Saturday, April 26, 2014 6:40 PM
  • hi, Stefan

    thank you for your reply

    you suggestion is a good idea, but it means much workload for people. 

    Monday, April 28, 2014 7:40 AM
  • hi, Stefan

    thank you for your reply

    you suggestion is a good idea, but it means much workload for people. 


                 

    I realize that it will be time-consuming, but I'm afraid there is no simple way to automate this.


    Stefan Blom, Microsoft Word MVP

    Monday, April 28, 2014 10:18 AM
  • hi, Cindy

    sorry for my poor description, i think i have misunderstanding the word's multilevel function. i will going to find a new way to solve this problem.

    thanks

    Monday, April 28, 2014 10:30 AM