I am using officer to manipulate a PowerPoint template in order to fill placeholders with values calculated in r.
Is there a way to do a search-and-replace to the texts in a slide?
I am using officer to manipulate a PowerPoint template in order to fill placeholders with values calculated in r.
Is there a way to do a search-and-replace to the texts in a slide?
To my knowledge,
officeronly provides the functionbody_replace_all_textfor Word files (docx), but no such function for PowerPoint.Fortunately, the
slide$get()function offers access to the XML document underlying the respective slide. The libraryxml2then allows to modify these nodes. Hope this snippet will save others the frustrating search through the packages.Note that replacing will only work if a text is actually stored in one XML tag. Avoid editing placeholder names after placing them in the text.