如何使用 VBA 确定 PowerPoint 中形状的文本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14442982/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 19:16:16  来源:igfitidea点击:

How to determine the text of a shape in PowerPoint using VBA

vbapowerpointmsgbox

提问by Josh-Mason

I simply want to grab text from a shape and display it somewhere else (Textbox, MsgBox...)

我只想从形状中抓取文本并将其显示在其他地方(文本框、消息框...)

I know this isn't correct but hopefully you can grasp the concept from this.

我知道这不正确,但希望您能从中掌握概念。

msgbox ("Do you want to overwrite " & slide1.slot1.value &, 36, "?")

slot1 = shapename

Any ideas?

有任何想法吗?

回答by Steve Rindsberg

Assuming that you're looking for the text in a shape named Slot1 on Slide 1 of the currently active presentation:

假设您正在当前活动演示文稿的幻灯片 1 上查找名为 Slot1 的形状中的文本:

Msgbox ActivePresentation.Slides(1).Shapes("Slot1").TextFrame.TextRange.Text