I have a Word file with a numbered list with some applied formatting for the text.
I need to remove the formatting of the text and keep text only but keeping the list numbering intact.
How I can I achieve this using VBA by iterating through the entire list with one item at a time.. pls advice.
BTW I'm a novice in using VBA but have a little knowledge of the basics.
Here's what I'm trying:
Public Sub Iterate_Paragraphs()
Dim Paragraph As Word.Paragraph
iParCount = ActiveDocument.Paragraphs.Count
Dim sMypar As String
For J = 1 To iParCount
sMypar = ActiveDocument.Paragraphs(J).Range.Text
sMypar.Copy
sMypar.PasteSpecial datatype:=wdPasteText
ActiveDocument.Paragraphs(J).Range.Text = sMypar
Next J
End Sub
CodePudding user response:
I'd refer you to this article
https://wordribbon.tips.net/T010248_Converting_Automatic_Numbering_to_Manual_Numbering.html
Which presents the following code
ActiveDocument.Range.ListFormat.ConvertNumbersToText
CodePudding user response:
To remove formatting, in addition to ActiveDocument.Range.ListFormat.ConvertNumbersToTex
you need to clear formatting and change the style for all text to the normal or body text style.