2017-01-17 66 views
0

我想改变选定形状的颜色。如果我点击一个形状,我点击一个按钮,我想改变红色的颜色,如图片,但当我按下按钮。如何在点击电源点按钮时着色形状?

我如何创建一个按钮,我把条件改变选择的颜色形状?

我试图通过按另一个形状来改变颜色,但不是我想要的。

非常感谢

enter image description here

回答

0

OK,所以,首先,因为你正在试图更改选定形状的颜色,这意味着你在正常(编辑)视图,而不是幻灯片。其次,只有在幻灯片放映模式下才能点击带有操作宏的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 

现在:添加您的宏变红。