Shading (object)

<< Click to Display Table of Contents >>

Shading (object)

Access paths:

Application à Workbooks à Item à Sheets à Item à Range à Shading

Application à Workbooks à ActiveSheet à Range à Shading

Application à ActiveWorkbook à ActiveSheet à Range à Shading

Application à ActiveSheet à Range à Shading

Instead of "Range", you can also use other objects and properties that return a Range object: ActiveCell, Selection, Rows(n), Columns(n) and Cells(x, y). You can find examples of these access paths in the Range-Object.

 1  Description

The Shading object represents the shading of cells (with either a shading or a pattern).

 2  Access to the object

The Shading object is a child object of a Range object and represents the shading of the cells in the given range, corresponding to the ribbon command Home | Format group | Shading.

Example:

' Show the pattern of cell A1

MsgBox pm.ActiveSheet.Range("A1").Shading.Texture

 3  Properties, objects, collections and methods

Properties:

Texture

Intensity

ForegroundPatternColor (default property)

ForegroundPatternColorIndex

BackgroundPatternColor

BackgroundPatternColorIndex

 

Objects:

Application Application

Parent Range

Texture (property)

Data type: Long (SmoShadePatterns)

Gets or sets the fill pattern for the shading. The possible values are:

smoPatternNone            =  0  (no shading)

smoPatternHalftone        =  1  (shading)

smoPatternRightDiagCoarse =  2 pm_shading_2

smoPatternLeftDiagCoarse  =  3 pm_shading_3

smoPatternHashDiagCoarse  =  4 pm_shading_4

smoPatternVertCoarse      =  5 pm_shading_5

smoPatternHorzCoarse      =  6 pm_shading_6

smoPatternHashCoarse      =  7 pm_shading_7

smoPatternRightDiagFine   =  8 pm_shading_8

smoPatternLeftDiagFine    =  9 pm_shading_9

smoPatternHashDiagFine    = 10 pm_shading_10

smoPatternVertFine        = 11 pm_shading_11

smoPatternHorzFine        = 12 pm_shading_12

smoPatternHashFine        = 13 pm_shading_13

To add a shading, set the Texture property to smoPatternHalftone and specify the required intensity of shading with the Intensity property.

To add a pattern, set the Texture property to one of the values between smoPatternRightDiagCoarse and smoPatternHashFine.

To remove an existing shading or pattern, set the Texture property to smoPatternNone.

Intensity (property)

Data type: Long

Gets or sets the intensity of the shading.

The possible values are between 0 and 100 (percent).

This value can be set or get only if a shading was chosen with the Texture property (i.e., the Texture property was set to smoPatternHalftone). If a pattern was chosen (i.e., the Texture property has any other value), accessing the Intensity property fails.

ForegroundPatternColor (property)

Data type: Long (SmoColor)

Gets or sets the foreground color for the shading or pattern as a "BGR" value (Blue-Green-Red triplet). You can either indicate an arbitrary value or use one of the pre-defined BGR color constants.

ForegroundPatternColorIndex (property)

Data type: Long (SmoColorIndex)

Gets or sets the foreground color for the shading or pattern as an index color. "Index colors" are the standard colors of PlanMaker, consecutively numbered from 0 for black to 15 for light gray. You may use the values shown in the Index colors table.

It is recommended to use the ForegroundPatternColor property (see above) instead of this one, since it is not limited to the 16 standard colors but enables you to access the entire BGR color palette.

BackgroundPatternColor (property)

Data type: Long (SmoColor)

Gets or sets the background color for the shading or pattern as a "BGR" value (Blue-Green-Red triplet). You can either indicate an arbitrary value or use one of the pre-defined BGR color constants.

BackgroundPatternColorIndex (property)

Data type: Long (SmoColorIndex)

Gets or sets the background color for the shading or pattern as an index color. "Index colors" are the standard colors of PlanMaker, consecutively numbered from 0 for black to 15 for light gray. You may use the values shown in the Index colors table.

It is recommended to use the BackgroundPatternColor property (see above) instead of this one, since it is not limited to the 16 standard colors but enables you to access the entire BGR color palette.

Application (pointer to object)

Data type: Object

Returns the Application object.

Parent (pointer to object)

Data type: Object

Returns the parent object, i.e. an object of the type Range.

Example for the Shading object

In the following example a 50% red shading will be applied to the range from A1 to C3.

Sub Main

 Dim pm as Object

 

 Set pm = CreateObject("PlanMaker.Application")

 pm.Visible = True

 

 With pm.ActiveSheet.Range("A1:C3")

                 .Shading.Intensity = 50

                 .Shading.ForegroundPatternColor = smoColorRed

 End With

 

 Set pm = Nothing

End Sub