ZolVas
ZolVas

Reputation: 298

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?

Upvotes: 2

Views: 6053

Answers (1)

ZolVas
ZolVas

Reputation: 298

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
  • Why this one? It is a little bit more flexible! Instead of Selection.Range you could use any other type of Range (ActiveDocument, ActiveDocument.Paragraphs, myRange.SetRange etc)

  • Just for your information, you don't need to save VBA if you don't want to. You can use Immediate Window to launch VBA.

    • Press alt+f11 (VBA-editor), then ctrl+g (Immediate Window).
    • Paste the code bellow, press enter.
    • Voilà!

Code (for Immediate Window):

ActiveDocument.ConvertNumbersToText

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

  • The result of any VBA here would be number+tab+text. If you want to have number+space+text you can:

    • either at the very end replace (press ctrl+h) this one .^t (dot and tab) for . (dot and whitespace),
    • or at the very beginning 1) select the list, 2) right click on it, 3) click "Adjuct list idents", 4) click "Follow number with: Space". (Look here: Adjust the spacing for a single list item (support.office))
  • You may need to have a leading zero in (auto-)numbering, then you can press ctrl+f9, write SEQ MyList \# "000" inside curly brackets, press alt+f9 to finish (look here: Insert fields in Word (support.office)). But this goes beyond the question, though you may find word fields really useful in some cases.


To sum up:

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

  • for Selection (look above);
  • for ActiveDocument (look above);
  • with a Range (examples in msdn);
  • with a loop (examples are welcomed). But bear in mind that you are to loop from the end of the document to the beginning.

Upvotes: 3

Related Questions