Reputation: 298
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
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.
alt+f11
(VBA-editor), then ctrl+g
(Immediate Window).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:
ctrl+h
) this one .^t
(dot and tab) for .
(dot and whitespace),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:
Upvotes: 3