ShadowFormat

Use the ShadowFormat object to add shadows to Shape objects. Use the Shape object’s Shadow property to get a reference to this object. The ShadowFormat object has the following members:

Application

Creator

ForeColor

IncrementOffsetX

IncrementOffsetY

Obscured

OffsetX

OffsetY

Parent

Transparency

Type

Visible

The ShadowFormat members correspond to the settings on the shadow toolbars shown in Figure 18-14.

Adding shadows

Figure 18-14. Adding shadows

To add a shadow to a shape, simply make the ShadowFormat object visible or set its Type property as shown here:

Sub ShadowFormatMembers( )
    Dim ws As Worksheet, s As Shape, fil As String
    Set ws = ActiveSheet
    ' Draw a rectangle.
    Set s = ws.Shapes.AddShape(msoShapeRectangle, 50, 50, 40, 60)
    ' Make it solid.
    s.Fill.Solid
    ' Set shadow type.
    s.Shadow.Type = msoShadow3
End Sub

If the shape is not solid, the shadow reflects the border of the object.

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.