7.6.4 Shading

Shading

Shading a range of cells is accomplished with the Interior object. Note that in Word, a Shading object is used, and in PowerPoint, a Fill object is used.

Table 4 shows the properties of the Interior object. Basically, you select a pattern, then apply a PatternColor to the pattern, and the Color property becomes the background color. However, it s tricky to predict the outcome. Just because the Color property is the background color does not mean that it is the less predominant color. Figure 9 illustrates this situation. White (actually, the automatic color) is the Color setting, and the PatternColor setting is black. Looking at the samples of the available patterns, you can see that some are predominantly white, and some are predominantly black.

It s obvious that Excel gives us lots of control over the patterning a cell. Here s a design caution: if you attempt to pattern a cell with anything other than a solid color, any text that s under about 36 points and appears on that pattern is difficult to read. We haven t found a terrific business need for patterns other than solid.

Actually, to shade a cell, you don t need to do anything other than change the Interior.Color property. Since it functions as a background color, and there s no pattern to display, the cell is shaded, and it only takes one line of code (rather than setting the Pattern to xlPatternSolid, and then setting the PatternColor). Shading is accomplished like this:

oSheet.Range("A14:C14").Interior.Color = RGB(192,192,192) && Light Gray

Table 4. Interior decorating. The Interior object has several properties to change the display of the cell.

Property

Type

Description

Color

RGB Color

The background color that shows through the pattern. If the pattern is a fine pattern (like the xlPatternLight patterns), this color becomes the predominant color, as the pattern itself does not dominate the cell.

InvertIfNegative

Logical or Numeric

Whether the pattern is inverted if the value of the shaded cell is negative. True (.T. or 1) to invert if negative, False (.F. or 0) to remain the same when negative.

Pattern

Numeric

Patterns the range with one of 20 predefined patterns.

xlPatternAutomatic

-4105

xlPatternHorizontal

-4128

xlPatternChecker

9

xlPatternLightDown

13

xlPatternCrissCross

16

xlPatternLightHorizontal

11

xlPatternDown

-4121

xlPatternLightUp

14

xlPatternGray8

18

xlPatternLightVertical

12

xlPatternGray16

17

xlPatternNone

-4142

xlPatternGray25

-4124

xlPatternSemiGray75

10

xlPatternGray50

-4125

xlPatternSolid

1

xlPatternGray75

-4126

xlPatternUp

-4162

xlPatternGrid

15

xlPatternVertical

-4166

 

PatternColor

RGB Color

The foreground color of the pattern. The Color property provides the background color.

 

Figure 9. The Format Cells dialog, with the Diagonal Stripe pattern selected. Note that the PatternColor is black, and the Color is Automatic, or white (it s obscured by the pattern window). Looking at all the pattern samples, it s easy to see the effect of the Color and PatternColor properties.

 

Copyright 2000 by Tamar E. Granor and Della Martin All Rights Reserved



Microsoft Office Automation with Visual FoxPro
Microsoft Office Automation with Visual FoxPro
ISBN: 0965509303
EAN: 2147483647
Year: 2000
Pages: 128

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net