|
本帖最后由 ning84 于 2024-8-24 12:56 编辑
从目前掌握的Excel 2007 没有模块代码。只能编程解决。
Sub SetShapeLineProperties()
Dim ws As Worksheet
Set ws = ActiveSheet
Dim Shp As Shape
Dim ShpRng As ShapeRange
Set ShpRng = Application.ActiveWindow.Selection.ShapeRange
Set Shp = Sheet3.Shapes(ShpRng.Name)
With Shp
Debug.Print .Line.ForeColor.RGB, .Line.BackColor.RGB, .Fill.BackColor.SchemeColor, .ShapeStyle
'.Fill.BackColor.ObjectThemeColor = msoThemeColorAccent6
'.Line.ForeColor.ObjectThemeColor = msoThemeColorFollowedHyperlink
'.Line.BackColor.SchemeColor = 42
End With
ColorArr Shp, 0, 0, 27, 29
End Sub
Function ColorArr(Shp As Shape, lineForeRGB, lineBackRGB, fillForeRGB, fillBackRGB)
With Shp.Shadow
.ForeColor.SchemeColor = 17
.OffsetX = 3
.OffsetY = 3
.Visible = msoCTrue
.Transparency = 0.5
End With
Stop
Dim Arr(29)
Arr(0) = Array("黑色black", 0, 0, 0)
Arr(1) = Array("红褐色maroon", 128, 0, 0)
Arr(2) = Array("红色red", 255, 0, 0)
Arr(3) = Array("橙色orange", 255, 128, 0)
Arr(4) = Array("黄色yellow", 255, 255, 0)
Arr(5) = Array("橄榄绿色olive", 128, 128, 0)
Arr(6) = Array("酸橙色lime", 128, 255, 0)
Arr(7) = Array("绿色green", 0, 255, 0)
Arr(8) = Array("青色cyan", 0, 255, 255)
Arr(9) = Array("蓝绿色teal", 0, 128, 128)
Arr(10) = Array("蓝色blue", 0, 0, 255)
Arr(11) = Array("海军蓝色navy", 0, 0, 128)
Arr(12) = Array("紫色purple", 128, 0, 128)
Arr(13) = Array("洋红色magenta", 255, 0, 255)
Arr(14) = Array("白色white", 255, 255, 255)
Arr(15) = Array("粉色pink", 255, 192, 203)
Arr(16) = Array("绯红色crimson", 220, 20, 60)
Arr(17) = Array("淡紫色lavender", 181, 126, 220)
Arr(18) = Array("靛色indigo", 75, 0, 130)
Arr(19) = Array("青绿色tarquoise", 64, 224, 208)
Arr(20) = Array("黄绿色chartreuse", 127, 255, 0)
Arr(21) = Array("浅黄色buff", 249, 233, 195)
Arr(22) = Array("米黄色beige", 247, 238, 214)
Arr(23) = Array("黄褐色tan", 210, 180, 140)
Arr(24) = Array("卡其色khaki", 195, 176, 145)
Arr(25) = Array("褐色brown", 150, 75, 0)
Arr(26) = Array("铜色copper", 184, 115, 51)
Arr(27) = Array("金色gold", 255, 215, 0)
Arr(28) = Array("银色silver", 192, 192, 192)
Arr(29) = Array("灰色grey/gray", 128, 128, 128)
With Shp.Line
.ForeColor.RGB = RGB(Arr(lineForeRGB)(1), Arr(lineForeRGB)(2), Arr(lineForeRGB)(3)) ' 设置线条颜色为红色
.BackColor.RGB = RGB(Arr(lineBackRGB)(1), Arr(lineBackRGB)(2), Arr(lineBackRGB)(3)) ' 设置线条背景色为黄色
.Weight = 2 ' 设置线条粗细为2磅
.DashStyle = msoLineSolid ' 设置线条样式为实线
End With
With Shp.Fill
.ForeColor.RGB = RGB(Arr(fillForeRGB)(1), Arr(fillForeRGB)(2), Arr(fillForeRGB)(3)) ' 设置线条颜色为红色
.BackColor.RGB = RGB(Arr(fillBackRGB)(1), Arr(fillBackRGB)(2), Arr(fillBackRGB)(3)) ' 设置线条背景色为黄色
End With
End Function
运行结果,不是目标需求 。也可能颜色学习不到位。
不是目标需求结果,预设的模块
|
|