VBA PowerPoint problem

  • Thread starter Thread starter Dominic_J
  • Start date Start date
D

Dominic_J

Guest
Hi,

I'm trying to do a search of about 600 PowerPoint slides where I have the wording Jones v Brown for example and replace the "v" with "!!" and then bold and highlight text. So it should look like:


Jones !! Brown


I can do the search and change the "v" to "!!" but I cannot work out how to bold (or highlight) the "!!". And when I insert some more code to bold (I've not included this code below) it bolds the entire slide instead of the "!!". Any ideas on what I'm missing or doing wrong? Many thanks in advance.


Sub regex()

Dim regX As Object

Dim osld As Slide

Dim oshp As Shape

Dim strInput As String

Dim strInput2 As String ' Extra variable - not required

Dim b_found As Boolean

Set regX = CreateObject("vbscript.regexp")
With regX
.Global = True
'Note + is a special character so \+
.Pattern = " v "
End With

For Each osld In ActivePresentation.Slides
For Each oshp In osld.Shapes
If oshp.HasTextFrame Then
If oshp.TextFrame.HasText Then

strInput = oshp.TextFrame.TextRange.Text

b_found = regX.Test(strInput)

If b_found = True Then

strInput = regX.Replace(strInput, " !! ")



oshp.TextFrame.TextRange.Text = strInput 'This puts the (changed) input of strInput into the text


'But I cannot work out how to select just the ' !!! ' and then bold and highlight it (or change the font size, etc for that matter of just that text)


End If
End If
End If
Next oshp
Next osld
End Sub

Continue reading...
 
Back
Top