Using PowerPoint 2016, I am writing a macro that allows the user to input data in a live presentation using UserForms and TextBoxes. This is working nicely, except when i try to display the text in a SmartArt. The following macro illustrates the problem:
Sub writeToSmartArt()
Dim artShape As Shape
Set artShape = ActivePresentation.Slides(maalSlide).Shapes("Diagram")
MsgBox artShape.SmartArt.Nodes(1).Nodes(1).TextFrame2.TextRange.Text
artShape.SmartArt.Nodes(1).Nodes(1).TextFrame2.TextRange.Text = "testing"
End Sub
The sub sets the SmartArt shape to the artShape variable, and first prints out the contents of a specified node in a MsgBox. In the next step, I am setting the text property to a new value. Everything works fine as long as the presentation is not active. I am able to manually run the sub, and everything behaves as expected. However, when the slideshow is running i get the following error message when trying to write to the SmartArt node:
Run-time error '-2147467259 (80004005)': Method 'Text' of object 'TextRange2' failed
Displaying the current content in the MsgBox still works. How can i overcome this problem?