PDA

View Full Version : Extract Lines with bullet points / number



smallxyz
06-29-2017, 12:26 AM
Hi all,

My document has the content like:

1. ***
*********XX
*********XX
2. ***XX ***
*********XX
3. XX
***
● ******
***X
***X ***X ***X
4. ***
***X
● ******


My concern is how to extract only numbered / bulleted line

The outcome would be :

1. ***
2. ***XX ***
3. XX
● ******
4. ***
● ******

Thanks !

gmayor
06-29-2017, 04:18 AM
Are the bullets/numbers simply text or are they inserted using bullets and numbering?

smallxyz
06-29-2017, 04:58 AM
They are inserted bullets.

gmayor
06-29-2017, 11:00 PM
In that case the following should work


Sub Macro1()
Dim oDoc As Document
Dim oTarget As Document
Dim oPara As Paragraph
Dim oRng As Range
Dim strStyle As String
Set oDoc = ActiveDocument
Set oTarget = Documents.Add
For Each oPara In oDoc.Paragraphs
strStyle = oPara.Style
If strStyle Like "List*" Then
Set oRng = oTarget.Paragraphs.Last.Range
oRng.FormattedText = oPara.Range.FormattedText
End If
Next oPara
lbl_Exit:
Set oPara = Nothing
Set oDoc = Nothing
Set oTarget = Nothing
Set oRng = Nothing
Exit Sub
End Sub

smallxyz
06-30-2017, 10:19 PM
Thanks man!