PDA

View Full Version : [SOLVED:] Paragraph sentences to bullet points



Programmer_n
08-24-2016, 04:42 AM
In VBAexpress i found a code to convert bullet points to paragraph


Sub ReplaceBullets()
Dim oPara As Paragraph
For Each oPara In Selection.Paragraphs()
If oPara.range.ListFormat.ListType = wdListBullet Then
oPara.range.ListFormat.RemoveNumbers _
NumberType:=wdNumberParagraph
oPara.range.InsertBefore Text:=" "
oPara.range.Text = Replace(oPara.range.Text, Chr(13), " ")
End If
Next
End Sub

Can the reverse be done? Converting paragraph to bullet points?

example this

On the Insert tab, the galleries include items that are designed to coordinate with the overall look of your document. You can use these galleries to insert tables, headers, footers, lists, cover pages, and other document building blocks. When you create pictures, charts, or diagrams, they also coordinate with your current document look.On the Insert tab, the galleries include items that are designed to coordinate with the overall look of your document. You can use these galleries to insert tables, headers, footers, lists, cover pages, and other document building blocks. When you create pictures, charts, or diagrams, they also coordinate with your current document look.

to


On the Insert tab, the galleries include items that are designed to coordinate with the overall look of your document.
You can use these galleries to insert tables, headers, footers, lists, cover pages, and other document building blocks.
When you create pictures, charts, or diagrams, they also coordinate with your current document look.On the Insert tab, the galleries include items that are designed to coordinate with the overall look of your document.
You can use these galleries to insert tables, headers, footers, lists, cover pages, and other document building blocks. When you create pictures, charts, or diagrams, they also coordinate with your current document look.

Paul_Hossler
08-24-2016, 06:25 AM
How would you want VBA to know where to break the paragraph?

Your example has 2 sentences in the first and second bullet

Programmer_n
08-24-2016, 06:42 AM
How would you want VBA to know where to break the paragraph?

Your example has 2 sentences in the first and second bullet

My bad corrected the error.

Paul_Hossler
08-24-2016, 05:39 PM
So each sentence in the paragraph so go to bullet point.

That would include sentences ending with ! and ? and maybe others

Programmer_n
08-24-2016, 06:26 PM
So each sentence in the paragraph so go to bullet point.

That would include sentences ending with ! and ? and maybe others

As usually sentences end with .!? it is necessary to identify it and give a line break and bullet the sentences. This happens within selection.paragraph range so only that paragraph is affected.

If there is a full stop that comes as a part of an abbreviation, then I run into problem.

So it would be better to check, If there is a space followed by capital letter after the punctuation mark to ensure certainty of end of sentence.

Also it is necessary to check the end of paragraph to bullet last point.

Programmer_n
08-25-2016, 06:40 AM
As usually sentences end with .!? it is necessary to identify it and give a line break and bullet the sentences. This happens within selection.paragraph range so only that paragraph is affected.

If there is a full stop that comes as a part of an abbreviation, then I run into problem.

So it would be better to check, If there is a space followed by capital letter after the punctuation mark to ensure certainty of end of sentence.

Also it is necessary to check the end of paragraph to bullet last point.



Sub ptob()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "[.]"
.Replacement.Text = ".^l"
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Range.ListFormat.ApplyBulletDefault
End Sub


In place of full stop, I replace with manual line break and added bullet points. But bullet only occurs for the first sentence.

Programmer_n
08-25-2016, 04:30 PM
Sub ptob()
'A basic Word macro coded by Programmer_n

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ". "
.Replacement.Text = ".^p"
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "? "
.Replacement.Text = "?^p"
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "! "
.Replacement.Text = "!^p"
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Range.ListFormat.ApplyBulletDefault
End Sub

Almost there on what I wanted to, only for abbreviations to play spoilsport. Have to be careful on it.
Not taking any effort on this any further.