<< 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
smoPatternLeftDiagCoarse = 3
smoPatternHashDiagCoarse = 4
smoPatternVertCoarse = 5
smoPatternHorzCoarse = 6
smoPatternHashCoarse = 7
smoPatternRightDiagFine = 8
smoPatternLeftDiagFine = 9
smoPatternHashDiagFine = 10
smoPatternVertFine = 11
smoPatternHorzFine = 12
smoPatternHashFine = 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