首页 > 解决方案 > 如何在 VBA 中将参数从文本传递到宏

问题描述

在为形状分配宏时,我知道您可以将形状作为参数传递,如下所示:

Sub DoSomething(CShp as Shape)
    'code here using CShp as shape obj
End Sub

在 PowerPoint 中,您还可以突出显示文本并在单击时为其分配一个宏。是否可以将已单击的文本作为参数传递?我尝试了以下想法无济于事:

Sub GetText(ShpText as Textframe)
'Nothing passes
End Sub

Sub GetText(ShpText as TextRange)
'Nothing passes
End Sub

Sub GetText(Shp as Shape)
Dim TxtRng as TextRange
Set TxtRng = Shp.TextFrame.TextRange
'Passes the whole text but not the clicked text only
End Sub

非常感谢

标签: vbapowerpoint

解决方案


推荐阅读