Hi, all:
Working with VBA on a PowerPoint project. I need to go btwn the tags and bold, italicize, underline as needed. Here is the code for the bold so far. It works great for the first instance, but after that...PFT! I know it's counting the tags properly, because I've gone through and counted them by hand.
Any help will be greatly appreciated.
Ron Repp
If gray hair is a sign of wisdom, then I'm a genius.
My newest novel: Wooden Warriors
Working with VBA on a PowerPoint project. I need to go btwn the tags and bold, italicize, underline as needed. Here is the code for the bold so far. It works great for the first instance, but after that...PFT! I know it's counting the tags properly, because I've gone through and counted them by hand.
Code:
Public Sub StartBoldProcess(ByVal sCharacter As String, ByVal EndCharacter As String)
Dim strLine As String
Dim BegPos As Integer
Dim NewPos As Integer
Dim EndPos As Integer
Dim Found As Boolean
Dim NewString As String
Dim i As Integer
Dim Lngth As Long
Set ActiveSlide = PP.ActivePresentation.Slides(124)
strLine = ActiveSlide.Shapes("Textbox 3") _
.TextFrame.TextRange.Text
For i = 1 To Len(strLine)
BegPos = FindStartPosition(strLine, sCharacter, 1)
If BegPos > 0 Then
Found = True
EndPos = FindEndPosition(strLine, EndCharacter, BegPos)
If EndPos > 0 Then
Found = True
RemPos = EndPos
EndPos = BegPos + EndPos - 1
If IsBold Then
BoldSelection BegPos + 3, EndPos
'ReplaceTags EndPos, EndPos + 3, EndBold, ""
'ReplaceTags BegPos, EndPos, sCharacter, ""
'RemPos = EndPos '- 7
Debug.Print "SlideNumber " & ActiveSlide.SlideNumber & ": BegPos " & BegPos & ": EndPos " & EndPos '& ": RemPos " & RemPos
End If
End If
End If
Next i
End Sub
Public Function FindStartPosition(ByVal strLine As String, ByVal String2Find, ByVal BegPos As Integer) As Integer
Dim POS1 As Integer
Dim Found As Boolean
POS1 = InStr(BegPos, strLine, String2Find, vbTextCompare)
If POS1 > 0 Then
Found = True
FindStartPosition = POS1
Else
Found = False
End If
End Function
Public Function FindEndPosition(ByVal strLine As String, ByVal String2Find, ByVal BegPos As Integer) As Integer
Dim POS1 As Integer
Dim Found As Boolean
Dim strNew As String
strNew = Mid(strLine, BegPos + 3, Len(strLine))
POS1 = InStr(BegPos, strNew, "<", vbTextCompare)
If POS1 > 0 Then
Found = True
Else
Found = False
End If
If Found Then
strReturn = Mid(strNew, BegPos, POS1 - 1)
RemPos = POS1 - 1
Debug.Print "End Pos: SlideNumber" & ActiveSlide.SlideNumber & ": RemPos " & RemPos
FindEndPosition = POS1 - 1
End If
End Function
Any help will be greatly appreciated.
Ron Repp
If gray hair is a sign of wisdom, then I'm a genius.
My newest novel: Wooden Warriors