Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Replacing line breaks

1,204 views
Skip to first unread message

Steve Rindsberg

unread,
Apr 1, 2009, 12:08:27 PM4/1/09
to
In article <69019CBB-2669-4EFD...@microsoft.com>, Ronaldo
wrote:
> Hi.
>
> Is there a way to incorporate line breaks in replaces (ctrl-H), in either
> the Find field or the Replace field?
>

PPT's find/replace feature is really limp, compared to Word's.

A little VBA might help:

Sub SandR()

Dim oSl As Slide
Dim oSh As Shape

For Each oSl In ActivePresentation.Slides
For Each oSh In oSl.Shapes
With oSh
If .HasTextFrame Then
If .TextFrame.HasText Then
With .TextFrame.TextRange
.Text = Replace(.Text, Chr$(11), vbCrLf)
' add more replacements as need be
' pipes with "plumbing"
.Text = Replace(.Text, "|", "lead-pipe-cinch")
End With
End If
End If
End With
Next
Next

End Sub

==============================
PPT Frequently Asked Questions
http://www.pptfaq.com/

PPTools add-ins for PowerPoint
http://www.pptools.com/

Echo S

unread,
Apr 1, 2009, 1:03:29 PM4/1/09
to
Oh, awesome. Saving this!

--
Echo [MS PPT MVP] http://www.echosvoice.com
What's new in PPT 2007? http://www.echosvoice.com/2007.htm
Fixing PowerPoint Annoyances http://tinyurl.com/36grcd
PowerPoint 2007 Complete Makeover Kit http://tinyurl.com/32a7nx


"Steve Rindsberg" <ab...@localhost.com> wrote in message
news:VA.00004b7...@localhost.com...

Steve Rindsberg

unread,
Apr 1, 2009, 3:15:38 PM4/1/09
to
In article <uPJ5Yvus...@TK2MSFTNGP06.phx.gbl>, Echo S wrote:
> Oh, awesome. Saving this!

Kewl.

Note that it'll only work on text in text boxes/placeholders and
autoshapes.

It won't see text in tables, graphics, SmartArt,
ThinksItsSmartButReallyItsOnlyCleverArt, StoopidArt, charts and other
such slidejetsam.

Oh, and due to changes between 2003 and 2007, you want to watch out for
those line endings.

2003/2007 both use 0b (chr$(11) for linebreaks and paragraph ends in
Titles, and linebreaks in other text and subtitles.

2003 uses 0D 0A or chr$(13)&Chr$(10) for paragraph ends in text and
subtitles

2007 uses 0D chr$(13) only for those situations.

====

caten

unread,
Jun 12, 2009, 10:00:01 PM6/12/09
to
I am trying to find all instances of ". " (a period followed by a space,
indicating the beginning of another sentence in the same paragraph) and
replace them with "." & vbCrLf (a period followed by a paragraph break) --
(here's my sticky part) -- except when the ". " falls within bullet text.

I tried the example in this thread (SandR), but it removes all existing text
formatting, and I can't figure out how to skip the bullet paragraphs.

Following various examples I found in the PPT VBA Reference as well as
pptfaq.com, I've come up with something that works fairly well, until I hit a
bullet paragraph. At that point, I want to skip ahead, by making the next
Find start after the previously found ". ", but the Find stops here, and I
get an "Object variable or with block variable not set" error.

Here's what I have. Any suggestions?


Sub FindReplaceNotesText()
' Loops through all Notes Body placeholders and changes
' ". " (period space) to a paragraph break

Dim oPres As Presentation
Dim oSl As Slide
Dim oNotesBox As Shape
Dim X As Long
Dim oTxtRng As TextRange
Dim oTmpRng As TextRange
Set oPres = ActivePresentation

For Each oSl In oPres.Slides
With oSl
For X = 1 To oSl.NotesPage.Shapes.Count
If .NotesPage.Shapes(X).Type = msoPlaceholder Then
' The shape is a placeholder
If .NotesPage.Shapes(X).PlaceholderFormat.Type =
ppPlaceholderBody Then
' The shape is a body placeholder
Set oNotesBox = .NotesPage.Shapes(X)
Set oTxtRng = oNotesBox.TextFrame.TextRange
oTxtRng.Select
Set oTmpRng = oTxtRng.Find(FindWhat:=". ")
oTmpRng.Select
Do While Not oTmpRng Is Nothing
If Not oTmpRng.ParagraphFormat.Bullet Then
Set oTmpRng = oTxtRng.Replace(FindWhat:=".
", _
Replacewhat:="." & vbCrLf, After:=2)
oTmpRng.Select
Set oTmpRng = oTxtRng.Find(FindWhat:=". ")
oTmpRng.Select
Else
MsgBox "This is bullet text!"
Set oTxtRng = ActiveWindow.Selection.TextRange
oTxtRng.Select
Set oTmpRng = oTxtRng.Find(FindWhat:=". ",
After:=2)
'here is where I need the search to start
'from where I last stopped, but instead I get an
'Object variable or with block variable not set error
oTmpRng.Select
End If
Loop
End If ' The shape is not a PlaceholderBody
End If ' The shape is not an msoPlaceholder
Next 'X oNotesBox
End With 'oSl
Next ' oSl

End Sub

I'd appreciate any ideas to "fix" what I have, or to go another way entirely.

0 new messages