Hi all:
This goes back to a prior thread: thread707-1712384 in which PHV, Combo and Strongm helped. The procedure worked great, but in Powerpoint, HTML does not format the same as it does on a Web page, so the client wants some changes.
I have a PP slide with a textbox. The textbox has unformatted HTML in it, and I need to replace what's btwn the tags with formatting (i.e. bold, etc). The code below works, but goes beyond the last instance of </b> (in this case).
If the client changes his mind again, I'm gonna brain him.
Thanks,
Ron Repp
If gray hair is a sign of wisdom, then I'm a genius.
My newest novel: Wooden Warriors
This goes back to a prior thread: thread707-1712384 in which PHV, Combo and Strongm helped. The procedure worked great, but in Powerpoint, HTML does not format the same as it does on a Web page, so the client wants some changes.
I have a PP slide with a textbox. The textbox has unformatted HTML in it, and I need to replace what's btwn the tags with formatting (i.e. bold, etc). The code below works, but goes beyond the last instance of </b> (in this case).
If the client changes his mind again, I'm gonna brain him.
Code:
Sub ReplaceText()
Dim strLine As String
Dim strNew
Dim Pos1 As Integer
Dim Pos2 As Integer
Dim Found As Boolean
Dim charRange As TextRange
Dim i As Integer
Dim NewPos As Integer
Do
strLine = Application.ActivePresentation.Slides(1).Shapes("Textbox 5") _
.TextFrame.TextRange.Text
For i = 0 To Len(strLine) - 1
If NewPos = 0 Then NewPos = 1
Pos1 = InStr(NewPos, strLine, "<b>", vbTextCompare)
If Pos1 > 0 Then
Found = True
Else
Found = False
Exit Sub
End If
If Found Then
Found = False
strNew = Mid(strLine, Pos1 + 3, Len(strLine))
Pos2 = InStr(Pos1, strNew, "<", vbTextCompare)
If Pos2 > 0 Then
Found = True
Else
Found = False
End If
End If
If Found Then
strNew = Mid(strNew, Pos1, Pos2 - 1)
Application.ActivePresentation.Slides(1).Shapes("Textbox 5") _
.TextFrame.TextRange.Characters(Pos1 + 3, Pos2 - 1).Font.Bold = msoCTrue
NewPos = Pos2
Found = False
Else
''no bolded HTML
GoTo GetNextI
End If
GetNextI:
Next i
Loop
End Sub
Thanks,
Ron Repp
If gray hair is a sign of wisdom, then I'm a genius.
My newest novel: Wooden Warriors