是否可以识别在 Powerpoint 演示文稿上触发鼠标悬停的形状 ID?

发布于 2024-10-25 13:01:33 字数 224 浏览 2 评论 0原文

是否可以识别在 Powerpoint 演示文稿上触发鼠标悬停的形状 ID。

我想要做的是在带有标题的幻灯片上显示一系列形状,当用户将鼠标悬停在形状上时,我想使用 VBA 在页面的另一部分(可能在单独的帮助文本中)显示有关该形状的更多详细信息盒子。然后,我可以使用选定的形状 ALT 文本来显示在帮助框中。我看不到的是如何识别触发鼠标悬停宏的形状。这可能吗?如果我可以识别触发该动作的形状,我就可以获取有关该形状的信息。

Is it possible to identify the shape ID that triggers a mouseover on a powerpoint presentation.

What I want to do is have a series of shapes on a slide with titles, and when the user mouseovers a shape, I want to use VBA to show more details about the shape in another part of the page, possibly in a separate help text box. I could then use the selected shapes ALt Text to display in the help box. What i can't see is how to identify what shape has triggered the mouseover macro. Is this possible? If I can identify the shape that triggered the action, I could then get info about that shape.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

赴月观长安 2024-11-01 13:01:48

PowerPoint 中的 Shape 对象不允许您像通常与 VBA 代码中的其他对象一样与其事件进行交互。仅有的两个公开的“事件”实际上并不是 VBA 事件。它们是一个名为 Actions 的特殊类,它们是“ppMouseOver”和“ppMouseClick”。如果您事先知道有关形状及其相应信息的所有信息,您可以编写一些代码来执行您想要的操作,但它全部都是硬编码的,这可能不是您想要的。

当演示开始时,您可以运行类似这样的例程:

Sub SetActionsRoutine()

    Shape1.ActionSettings(ppMouseOver).Action = ppActionRunMacro
    Shape1.ActionSettings(ppMouseOver).Run = "showInformation1"

    Shape2.ActionSettings(ppMouseOver).Action = ppActionRunMacro
    Shape2.ActionSettings(ppMouseOver).Run = "showInformation2"
    ...
    ...
End Sub

然后每当您对这些形状进行鼠标悬停时,都会运行以下例程之一。

Sub showInformation1()
    myTextBox.Text = Shape1.AlternativeText
End Sub

Sub showInformation2()
    myTextBox.Text = Shape2.AlternativeText
End Sub

这是非常有限的,需要您为幻灯片上的每个形状编写一个子例程。可能不是您想要的方法,但同样,使用 PowerPoint,您的选择非常有限。

The Shape object in PowerPoint does not allow you to interact with its events as you normally would with other objects in VBA code. The only two 'events' that are exposed are not actually VBA events. They are a special class called Actions, and they are 'ppMouseOver' and 'ppMouseClick'. If you know all the information about your shapes and their corresponding information beforehand, you could write some code to do what you want, but it would all be hard-coded, which is probably not what you want.

You could run a routine something like this when the presentation starts:

Sub SetActionsRoutine()

    Shape1.ActionSettings(ppMouseOver).Action = ppActionRunMacro
    Shape1.ActionSettings(ppMouseOver).Run = "showInformation1"

    Shape2.ActionSettings(ppMouseOver).Action = ppActionRunMacro
    Shape2.ActionSettings(ppMouseOver).Run = "showInformation2"
    ...
    ...
End Sub

And then whenever you did a MouseOver of those shapes, one of the following routines would run.

Sub showInformation1()
    myTextBox.Text = Shape1.AlternativeText
End Sub

Sub showInformation2()
    myTextBox.Text = Shape2.AlternativeText
End Sub

This is very limited and requires that you write a subroutine for every shape on your slide. Probably not the approach you want, but again, with PowerPoint, your options are very limited.

榆西 2024-11-01 13:01:48

StackOverflow 新手,迟来回答,但您可以执行以下操作:

Sub RespondToShape(oSh as Shape)
  MsgBox "You clicked " & oSh.Name
End Sub

分配您想要与运行宏的操作设置交互的每个形状,并选择 RespondToShape 作为宏。

New to StackOverflow, late to answer, but you can do this:

Sub RespondToShape(oSh as Shape)
  MsgBox "You clicked " & oSh.Name
End Sub

Assign every shape you want to interact with an Action setting of Run Macro and choose RespondToShape as the macro.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文