none
How can i find the List-Value of a Selection with VBA? (Microsoft Word, Office 2010) RRS feed

  • Question

  • I have a todolist.
    And i have to find out which number value the selection has.

    ----- For example:

    1. Text
        Text

    2.1. Text
           Selected Text

    2.2. Text
           Text
           Text

    2.3. Text

    -----If i select the select the text with "Selection.Range.Text", there is no number.
    I can get the number wich "Selection.Copy", but i
    do not think this is a good way

    Monday, April 7, 2014 6:52 AM

Answers

All replies

  • What is the logic that determines what number applies to your selected text. Eg, in your example is the selected text is in B4 and do you want to return the value in A4, or if A4 is empty the first non empty cell above it, in the example A3 with 2.1. 
    Monday, April 7, 2014 11:15 AM
    Moderator
  • I don't work in Excel. I work in Word.

    The logic of the numbering comes from the List-Style.
    The numbering is specified by the user.
    You can see an example here:
    http://office.microsoft.com/en-us/word-help/number-your-headings-HA010282072.aspx

    Yes, there is no numbering in the selected Line, the number of the next line above with numbering is the wanted value. (In my example 2.1)

    Monday, April 7, 2014 11:42 AM
  • Sorry I misread

    What about this

    idx = Selection.Range.ListFormat.ListString

    Monday, April 7, 2014 12:50 PM
    Moderator
  • Thanks!
    That's it.
    Friday, April 11, 2014 9:54 AM