Powerpoint VBA在鼠标点击时突出显示图像

时间:2014-07-29 13:41:54

标签: vba onclick powerpoint powerpoint-vba

我有PowerPoint 2013演示文稿。在第一张幻灯片上,我有15张图片。鼠标单击图像会更改VBA宏中的变量,但它看起来不像用户点击过的图像,因此如果它们单击它们可能会造成混淆。

我想改变他们点击的图片,以显示它被点击了。我不在乎它的高光或阴影或图像是否改变。

Sub Resize()
    With ActiveWindow.Selection.ShapeRange
        .Height = 2.78 * 72
        .Width = 4.17 * 72
        .Left = 0.78 * 72
        .Top = 1.25 * 72
        .ZOrder msoSendToBack
    End With
End Sub

Sub DefButton1Clicked()
    Element1 = 1
    Resize
End Sub

这不起作用。

好的,我在这里想到了这就是我所做的:

Sub DefButton1Clicked(oSH As Shape)
Element1 = 1
MsgBox oSH.Name
oSH.Shadow.Type = msoShadow17
oSH.Shadow.ForeColor.RGB = RGB(0, 0, 128)
oSH.Shadow.OffsetX = 3
oSH.Shadow.OffsetY = 2
End Sub

点击一个按钮后,我也可以重置另一个按钮:

Dim oImg1 As Shape
Set oImg1 = ActivePresentation.Slides(1).Shapes.Item("Picture 7")
oImg1.Shadow.Visible = msoFalse
Dim oImg2 As Shape
Set oImg2 = ActivePresentation.Slides(1).Shapes.Item("Picture 8")
oImg2.Shadow.Visible = msoFalse

1 个答案:

答案 0 :(得分:0)

社区维基。答案就在问题中。任何在搜索中找到此主题的人都会看到答案,并且更有可能寻找有希望的有用答案。

好的,我在这里想到了这就是我所做的:

Sub DefButton1Clicked(oSH As Shape)
Element1 = 1
MsgBox oSH.Name
oSH.Shadow.Type = msoShadow17
oSH.Shadow.ForeColor.RGB = RGB(0, 0, 128)
oSH.Shadow.OffsetX = 3
oSH.Shadow.OffsetY = 2
End Sub

点击一个按钮后,我也可以重置另一个按钮:

Dim oImg1 As Shape
Set oImg1 = ActivePresentation.Slides(1).Shapes.Item("Picture 7")
oImg1.Shadow.Visible = msoFalse
Dim oImg2 As Shape
Set oImg2 = ActivePresentation.Slides(1).Shapes.Item("Picture 8")
oImg2.Shadow.Visible = msoFalse