Hi,
I am struggling with the following problem:
My goal is to replace some text in the slide notes of a PowerPoint file using VBA. If the text in the slide notes looks like this (single occurence of the tag to be deleted) my code below works. However, for multiple occurences of the tags it does not work correctly.
The input in this case looks like this:
This is a first sentence.
<code1>This second sentence needs to be deleted.</code1>
Here is a third sentence. This one should be kept.
<code1>This fourth sentence needs to be deleted as well.</code1>
And the wrong output like this:
This is a first sentence.
Actually, I want to have this:
This is a first sentence.
Here is a third sentence. 'This one should be kept.
I would appreciate any advice on how to change the code below.
Sub sync_text()
input_text = ActivePresentation.Slides(1).NotesPage.Shapes(2).TextFrame.TextRange.Text
' Delete code1
Set regX_delete = CreateObject("vbscript.regexp")
With regX_delete
.Global = True
.Pattern = "<code1>(.+)</code1>"
End With
output_text = regX_delete.Replace(input_text, " ")
ActivePresentation.Slides(1).NotesPage.Shapes(2).TextFrame.TextRange.Text = output_text
End Sub
Thanks for your help!