Macro: How to recognize multiple sentences in a single bullet?

D

david.f.jenkins

I'm writing a macro to format text in the body of a slide. There are
specific rules for the formatting of bulleted text, for formatting
sentences contained in bullets and for the formatting of mulitple
sentences occurring within a single bullet.

If I see that a text range contains, say, 4 sentences, how can I
ascertain a) which of those is contained in a bullet, and b) which
bullet a given sentence is in?
 
S

Steve Rindsberg

I'm writing a macro to format text in the body of a slide. There are
specific rules for the formatting of bulleted text, for formatting
sentences contained in bullets and for the formatting of mulitple
sentences occurring within a single bullet.

If I see that a text range contains, say, 4 sentences, how can I
ascertain a) which of those is contained in a bullet, and b) which
bullet a given sentence is in?

There's really no such animal as "contained in a bullet" but I know what you
mean. In this case bullet = paragraph. Does this help:

Sub SentencesVsParagraphs()

Dim oSh As Shape
Dim x As Long
Dim y As Long

' Assumes a text box with some text is selected
Set oSh = ActiveWindow.Selection.ShapeRange(1)
With oSh.TextFrame.TextRange
For x = 1 To .Paragraphs.Count
Debug.Print "Paragraph " & x
With .Paragraphs(x)
For y = 1 To .Sentences.Count
Debug.Print .Sentences(y).Text
Next ' y = sentence
End With
Next ' x = paragraph
End With

End Sub
 
D

david.f.jenkins

That's very helpful, Steve - thanks!

Unfortunately, it's a little more complicated than I perhaps explained
earlier. (Ain't that always the case?) Here're the rules this macro
is intended to enforce:

1) Sentences in normal (unbulleted, i.e.) paragraphs are to end with
periods. (Duh)
2) Sentences in bulleted paragraphs are to be terminated using the
following rule:
a) If the bullet consists of only one sentence, it is NOT to be
terminated with a period
b) If the bullet consists of > 1 sentence, then ALL the sentences
are to be terminated with a period.

Hence my requirement to be able to ascertain whether a paragaph is
bulleted or not. I do see some properties that deal with bullets, but
I'm just not sure how I can take advantage of those to do what I'm
trying to accomplish.

Any further suggestions?

Thanks!
 
D

david.f.jenkins

OK, Steve - I think I have it worked out.

I can interrogate the Bullet visible status of a a paragraph, and then
if it's visible (bulleted), I can go from there, checking to see if
there's more than one sentence, and then checking the termination
charater of the last sentence, etc.

It all seems to be working ok - thanks for your help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top