Get Word Document List Number Hierarchy

Discussion in 'Word VBA' started by, Feb 10, 2014.

  1. Guest

    I would like to be able to get out the full list number hierarchy of wherever I am in a document. So if i have

    1 Top Level text
    1.1 Second Level text
    (a)Third Level text item 1
    (b)Third Level text item 2

    and I have some text highlighted on the (b) line, I would like to build a string 1-1.1-(b)

    I relise i can get the "(b)" on its own by:

    but I dont know how to go from that to the next level up in the hierarchy ie 1.1

    Thanks in advance if anyone can help me.
    , Feb 10, 2014
    1. Advertisements

  2. Stefan Blom Guest

    What are you trying to accomplish? If you are creating a cross-reference,
    you can do so via the Cross-reference dialog box (References tab |
    Cross-reference). For "Reference type," choose "Numbered item." In the
    "Insert reference to" drop down, select "Paragraph number (full context)."
    The "full context" option will always include higher levels in the numbering
    Stefan Blom, Feb 15, 2014
    1. Advertisements

  3. Guest

    Thanks Stefan. I know all about the cross-refernce box and elsewhere in my code I a using that the information in it, but doesn't help me for this. The cross-refernce information is poor and you have to mess around with numbers of spaces to find out what level things are at, which I have done. However For this bit of the code, wherever I am in my document, i need to know about the complete family list that I am inso that I can relate it back to the cross-reference. So as the example shows in my first post, knowing "(b)"doesn't help me in code to know where we are in the cross-refernce as there could be many nodes that start (b). Hence why I want to find the full family path of "(b)" so that I can key it back to the cross reference.

    However I have now managed to do this by writing a loop and using GoToPrevious to find out each parent level of where I am.
    , Feb 18, 2014
  4. Stefan Blom Guest

    "Full context" should give you just that: the complete reference, including
    all higher levels in the numbering scheme. Obviously, I'm missing something
    Stefan Blom, Feb 18, 2014
  5. Guest

    Maybe I'm missing something obvious, but I can't see "full context" is available to me unless im adding a cross-refernce to another range? In VBA, am I able to find the full context of any range ie something along the lines of:
    strMyString = Selection.Range.FullContext
    If so, can you tell me how to write that properly?
    My point is that I am not wanting to add a cross-reference, but I want to use the family structure of any range in the document to do some checking
    , Feb 24, 2014
  6. Stefan Blom Guest

    Stefan Blom, Mar 7, 2014
  7. KrystalSkul

    Jan 15, 2015
    Likes Received:
    Did anyone ever get an answer for this? I am trying to do the same thing.

    The reason for needing this is that I need to generate a separate document of certain noncontiguous selected paragraphs in the main document. I want the macro to paste the full context of the paragraph I am copying and pasting.
    Is there an easy way to do this, or do I have to trace back each list level and build a string that way?

    The full context information is obviously tracked in Word, but how do I access the full context paragraph number for a selected paragraph in VBA?

    I don't think there is a paste option that does this. So what is the variable that stores the full context paragraph number for cross references that insert the full context number. I want to store the value of this variable for use with the paragraph in the second document.
    KrystalSkul, Jan 15, 2015
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.