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.