Reputation: 1
I have selected the text in table cell of powerpoint as below picture shows table in powerpoint
when I run the vba sub which is as below
Sub changeSelectedText()
Set ppapp = GetObject(, "Powerpoint.application")
Set pppres = ppapp.ActivePresentation
Dim text As String
text = "cell content change"
selectionType = ppapp.ActiveWindow.Selection.Type
ppapp.ActiveWindow.Selection.TextRange.text = text
End Sub
the error occured on the line: ppapp.ActiveWindow.Selection.TextRange.text = text
so I can not change the selected text in the table cell of powerpoint.
Upvotes: 0
Views: 390
Reputation: 14809
If your code will run from within PowerPoint itself, this works:
Sub changeSelectedText()
Dim text As String
text = "cell content change"
ActiveWindow.Selection.TextRange.text = text
End Sub
If you're driving PPT from another app, try this for starters. Aircode. Untested. Caveat computor:
Sub changeSelectedText()
Dim ppapp as object
Dim pppres as Object
Set ppapp = GetObject(, "Powerpoint.application")
Set pppres = ppapp.ActivePresentation
Dim text As String
text = "cell content change"
' You haven't declared selectionType and don't
' use it for anything, so I've commented it out
' selectionType = ppapp.ActiveWindow.Selection.Type
ppapp.ActiveWindow.Selection.TextRange.text = text
End Sub
Upvotes: 1