0

我想更改选定形状的颜色。如果我单击一个形状并单击一个按钮,我想将颜色更改为红色,如图所示,但是当我按下按钮时。

我如何创建一个按钮来更改选定的颜色形状?

我试图通过按下其他形状来改变颜色,但这不是我想要的。

非常感谢

在此处输入图像描述

4

1 回答 1

0

好的,首先,因为您正在尝试更改所选形状的颜色,这意味着您处于正常(编辑)视图而不是幻灯片放映中。其次,只有在幻灯片放映模式下才能单击带有运行宏的操作的 ActiveX 按钮或形状。因此,普通视图中“按钮”的唯一选择是使用 Office 的功能区可扩展性功能。您需要将按钮的 XML 添加到 PowerPoint 文件的 customUI 并创建关联的宏以使其运行。例如,使用CustomUI Editor将此 XML 添加到您的文件中:

// Fluent UI customisation to add a single button to the PowerPoint ribbon //
// Written by Jamie Garroch of YOUpresent Ltd. http://youpresent.co.uk //
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
  <ribbon>
    <tabs>
      <tab id="tabMyTab" label="My Tab">
        <group id="grpMyGroup" label="My Group">
          <button id="btnMyButton" label="My Button" onAction="MyMacro"/>
        </group>
      </tab>
    </tabs>
  </ribbon>
</customUI>

...然后在 CustomUI 编辑器中关闭文件并在 PowerPoint 中重新打开。然后添加你的宏:

' PowerPoint macro to change the fill colour of a single selected shape
' Written by Jamie Garroch of YOUpresent Ltd. http://youpresent.co.uk
Public Sub MyMacro(control As IRibbonControl)
  With ActiveWindow.Selection
    If .Type = ppSelectionShapes Then
      If .ShapeRange.Count = 1 Then
        If .ShapeRange.Type = msoAutoShape Then
          .ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
         End If
      End If
    End If
  End With
End Sub

现在,当您在自定义选项卡My Tab中单击My Button时,如果在视图中的幻灯片上有一个选定的 AutoShape 类型的形状,则填充颜色将变为红色。

于 2017-01-17T13:13:20.937 回答