vbams-word

Convert automatic numbering and bullets to plain text


I have a word document with automatic numbering and bulleting.

I have selected the text where I need to convert automating numbering and/or bulleting to normal text.

In addition I need to keep both the formatting and numbers/bullets of the selected text.

What I have already tried:

Code (error, method or data member not found):

Sub convertNumbersAndBulletsToText()
   Selection.ConvertNumbersToText
End Sub

What would you recommend me to do in order to keep both formatting and numbers/bullets?


Solution

  • You have practically done everything yourself!

    This code will work:

    Sub convertNumbersAndBulletsToText()
       Selection.Range.ListFormat.ConvertNumbersToText
    End Sub
    

    Your example returns error because ConvertNumbersToText method doesn't work with Selection. It works with Range!

    (look here: Change selected automatic numbered list to plain text in word)


    Beware!

    If you want to carry out many changes, you may find it easier to make them with ActiveDocument (look below).

    But if want to do it manually (or through a loop),
    then you'd better loop from the last element you want to convert till the first one
    (not vice versa, because auto-numbers would then increment by one all the time)!


    Small Tips

    Personally I would recommend you to use this code instead:

    Sub convertNumbersAndBulletsToText()
       Dim myRange As Range
       Set myRange = Selection.Range
       myRange.ListFormat.ConvertNumbersToText
    End Sub
    

    Code (for Immediate Window):

    ActiveDocument.ConvertNumbersToText
    

    (It converts auto-numbers and auto-bullets to normal numbers and bullets everywhere in ActiveDocument).


    To sum up:

    You can replace both bullets and numbers for plain text in Word: