Working with Glow and Reflection Properties in Office 2010
Programmatically Working with Shapes in Office 2010: Learn how to manipulate text in a Microsoft Word 2010 document by adding glow and reflection effects.
Applies to: Microsoft Word 2010
Published: April 2011
Provided by: Frank Rice, Microsoft Corporation
Formatting text with a glow effect is an excellent way to make the text stand out. Similarly, mirroring text draws attention to it by displaying a duplicate image as a reflection of the text. In this topic, you programmatically manipulate the glow and reflection properties of text. To complete this task, you must do the following:
Add a Standard Module to a Word Document
In this task, you open a Word 2010 document, open the Visual Basic Editor, and then insert a standard module.
To add a standard module to a Word document
Start Word 2010.
On the Developer tab, click Visual Basic to open the Visual Basic Editor.
If you do not see the Developer tab in Word 2010, click the File tab, and then click Options. In the categories pane, click Customize Ribbon, select Developer, 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.
Add the Code to the Visual Basic Editor
In this task, you use programming code to add text to a document and then apply glow and reflection effects to that text.
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 TestGlowAndReflection() ActiveDocument.Range.InsertBefore "Here is some text." With ActiveDocument.Range.Paragraphs(1).Range With .Font .Size = 24 .ColorIndex = wdRed ' Work with the Font.Glow property: With .Glow ' Can also set the Color.RGB property: .Color.ObjectThemeColor = wdThemeColorAccent1 .Radius = 10 .Transparency = 0.8 End With With .Reflection .Offset = 2.4 .Blur = 0.5 .Size = 100 .Transparency = 0.5 ' You can also set the Type property, which ' includes settings for the preset Reflection ' types: ' .Type = msoReflectionType1 End With End With End With End Sub
Test the Solution
In this task, you step through the code and watch as it adds text to the document and then manipulates that text. The best way to see the code in action is to place the Visual Basic Editor window and the Word window side-by-side.
To step through the code
Drag the Visual Basic Editor to the right side of your monitor.
Drag the Word window to the left side of your monitor and adjust the windows until you can see them both.
Place the cursor in the TestGlowAndReflection module, press F8 to step through the code line-by-line.
Applying the glow properties looks similar to Figure 1.
Figure 1. Text with a Glow
Applying the reflection properties looks similar to Figure 2.
Figure 2. Text with Reflection