[英]vba power point : how to change the selected text in table cell in powerpoint?
I have selected the text in table cell of powerpoint as below picture shows table in powerpoint 我在PowerPoint的表格单元格中选择了文本,如下图所示在PowerPoint中的表格
when I run the vba sub which is as below 当我运行如下的vba sub时
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 该错误发生在以下行:ppapp.ActiveWindow.Selection.TextRange.text = text
so I can not change the selected text in the table cell of powerpoint. 因此,我无法在powerpoint的表格单元中更改所选文本。
If your code will run from within PowerPoint itself, this works: 如果您的代码将在PowerPoint本身中运行,则可以:
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. 如果您是从其他应用程序驱动PPT,请尝试使用此工具。 Aircode.
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.