PDA

View Full Version : replace number characters with "numbering" bullet points



djswingline
04-13-2010, 08:56 AM
Hi There,

I'm new to using VBA in word, but have some experience with VBA in excel. I was wondering if it is possible to use vba to replace numbers entered as regular text with numbering bullet points. I have a number of very large documents where ordered lists were entered by hand using "1-", "2-", etc... and carriage returns and need to convert them.

Any help would be much appreciated

macropod
04-13-2010, 11:35 PM
Hi djswingline,

It's not clear what you mean about the carriage returns and 'numbering bullet points'. If you mean the affected paragraphs look like:
1- Some text.¶
and you want them to be numbered using an automatic numbering scheme, then something based on the following macro should do the trick.

Sub Demo()
Dim oPara As Paragraph
For Each oPara In ActiveDocument.Paragraphs
With oPara.Range
If .Words.Count > 1 Then
If IsNumeric(.Words(1)) And Trim(.Words(2)) = "-" Then
.Words(2).Delete
.Words(1).Delete
.Style = "Heading 2"
End If
End If
End With
Next
End Sub
The above macro applies the 'Heading 2' Style to the paragraph - choose whatever numbered paragraph Style you'd prefer to use (attributes modified as required).