Using Glow and Reflection Properties in Office 2010
Programmatically Working with Shapes in Office 2010: Learn how to work with the glow and reflection properties in Microsoft PowerPoint 2010.
Last modified: May 20, 2011
Applies to: Excel 2010 | Office 2010 | PowerPoint 2010 | VBA | Word 2010
Published: June 2011
Provided by: Frank Rice, Microsoft Corporation
You can enhance images or text by adding effects, such as shadows, glows, reflections, soft edges, bevels, and three-dimensional (3-D) rotations to them. In this topic, you programmatically add a shape in a Microsoft PowerPoint 2010 presentation. You then manipulate the glow and reflection properties of the shape. To complete this task, you must do the following:
In this task, you open a PowerPoint 2010 presentation, open the Visual Basic Editor, and then insert a standard module.
To add a standard module to a PowerPoint presentation
Start PowerPoint 2010.
On the Developer tab, click Visual Basic. This opens the Visual Basic Editor.
If you do not see the Developer tab in PowerPoint 2010, click the File tab, and then click Options. In the categories pane, click Popular, select Show Developer tab in the Ribbon, and then click OK.
On the Insert menu, click Module. This adds Module1 to the Projects pane on the left side of the Visual Basic Editor.
In this task, you add programming code to the Visual Basic Editor.
To add code to the Visual Basic Editor
In the Projects pane, click Module1.
Paste or type the following Microsoft Visual Basic for Applications (VBA) code into the module window.
Sub GlowAndReflectionDemo() ' Work with Shape Glow and Reflection properties. ' Create a blank slide. Dim sld As Slide Set sld = ActivePresentation.Slides.Add(2, ppLayoutBlank) ' Add a shape to the new slide. Dim shp As Shape Set shp = sld.Shapes.AddShape(msoShape5pointStar, 100, 100, 200, 200) sld.Select With shp.Glow ' This code is only meaningful if you single-step through it. ' Note that the user interface offers presets, which aren't exposed ' through the object model. ' Pick a starting color. .Color.ObjectThemeColor = msoThemeColorAccent2 ' Radius corresponds to the Size property in the user interface, and is ' measured in points. ' Try a few sizes: .Radius = 8 .Radius = 20 .Radius = 50 ' Try varying transparencies: .Transparency = 0 .Transparency = 0.25 .Transparency = 0.5 .Transparency = 0.75 ' Try a few colors: .Color.ObjectThemeColor = msoThemeColorAccent5 .Color.ObjectThemeColor = msoThemeColorAccent6 .Color.RGB = RGB(255, 255, 128) End With ' Work with the shape's reflection. ' Single step through this code to see the changes. With shp.Reflection ' Cycle throught the 9 built-in reflection types: .Type = msoReflectionType1 .Type = msoReflectionType2 .Type = msoReflectionType3 .Type = msoReflectionType4 .Type = msoReflectionType5 .Type = msoReflectionType6 .Type = msoReflectionType7 .Type = msoReflectionType8 .Type = msoReflectionType9 ' Transparency is treated as a percentage, with 1 being completely transparent, and 0 being nearly opaque: .Transparency = 0.9 .Transparency = 0.7 .Transparency = 0.5 .Transparency = 0.3 ' Size is measured as a percentage of the original shape, times 100: .Size = 10 .Size = 25 .Size = 50 .Size = 75 .Size = 100 .Size = 60 ' Offset corresponds to the Distance property in the user interface, measured in points. ' It indicates how far from the shape to draw the reflection: .Offset = 0 .Offset = 10 .Offset = 20 ' Blur is measured in points, indicating the amount of blur to add to the reflection: .Blur = 2 .Blur = 5 .Blur = 10 End With End Sub
In this task, you step through the code. The best way to see the code in action is to place the Visual Basic Editor and the PowerPoint screen side-by-side.
To run the code
Drag the Visual Basic Editor to the right side of the screen.
Next, drag the PowerPoint screen to the left side of the screen and adjust both screens until you can see clearly.
Place your cursor in the GlowAndReflectionDemo module and then press F8 to step through the code line-by-line and watch the results.