e800
,国内最具活力的
IT
门户网站。
http://www.e800.com.cn
【
e800
编译】
此示例演示在
Microsoft Excel 2010
中如何使用
FillFormat
对象的渐变填充
功能。
此代码段是
Office
2010
的
101
项
VBA
代码示例中的一部分。与其它示例一样,这些将
可以直接写入您的代码中。
每块示例代码包含约
5
至
50
行的代码,分别演示了一个独特的功能或功能集,在
VBA
或
VB
以及
C
#中
(在
Visual Studio 2010
中创建)
。
每个示例之中都会包含代码以及相应注释,
这样您就可以直接运行获取预期的结果,
或者是根据代码注释提示来调整环境,
运行示例代
码。
Microsoft
Office
2010
提供了你所需要的工具来创建功能强大的应用程序。
Microsoft
Visual
Basic
Application
(
VBA
)代码示例可以帮助你创建自己的应用程序,以执行特定功能
或者以此为出发点实现更为复杂的功能。
实例代码
在
Excel
2010
中新建工作簿,复制下列所有代码到
Sheet1
类模块,将光标置于
GradientDemo
内,按
F8
单步执行代码。并列放置
VBA
和
Excel
窗口,这样你就可以参考注
释中的提示。
Sub
GradientDemo()
Dim
rng
As
Range
Set
rng=Range(
"B2:C10"
)
rng.Cells.Merge
Dim
grd1
As
LinearGradient
rng.Interior.Pattern=XlPattern.xlPatternLinearGradient
Set
grd1=rng.Interior.Gradient
Dim
cs
As
ColorStop
' Set the gradient to be tilted by 10 degrees:
grd1.Degree=
10
' Add a color stop at 25% of the width:
Set
cs=grd1.ColorStops.Add(
0.25
)
cs.Color=vbYellow
' Set the shading: -1 is black, 1 is white, 0 is the full color.
' Setting this to 0.25 makes it a little paler.