Sub Beta2()
Dim oshp As Shape, osld As Slide, TxtChng As String, i As Integer
For Each osld In ActivePresentation.Slides
For Each oshp In osld.Shapes
If oshp.HasTextFrame Then
If oshp.TextFrame.HasText Then
TxtChng = InStr(oshp.TextFrame.TextRange.Characters.Text, ChrW(&H3B2) & "2")
If TxtChng > 0 Then
For i = 1 To 3
With oshp.TextFrame.TextRange.Characters(foundAt + 1)
.Font.Subscript = True
End With
Next i
End If
End If
End If
Next oshp
Next osld
End Sub
Before I expand this code to have the option to have a user defined search term (rather than being fixed to β2, as it is now), I've realised that something is still not quite right with this. I think I know, broadly, what is going wrong, but I don't know how to set it right.
The code as it currently stands will only change β2 to β2 for the first instance in each text box. If there is more than one β2 in the text box, it will only do the first one. I tried adding the i loop, thinking this would make it run through the whole text box, but I realise now that this was stupid, and that it's just applying the change to the first β2 three times!
Is there a way to get this to change ALL of the β2 in each text box to β2?
My grand plan is to expand this code to be a functioning search and replace for text that needs superscripts and subscripts (hence my previous question about versatile inputboxes), but I want to get this bit right before trying out anything more extensive.
Thanks for your help!