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:
And the wrong output 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>
Actually, I want to have this:This is a first sentence.
I would appreciate any advice on how to change the code below.This is a first sentence. Here is a third sentence. 'This one should be kept.
Thanks for your help!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




Reply With Quote
