本帖最后由 ning84 于 2024-10-23 19:16 编辑
- Function RetuColorRGB(Str)
- Dim Arr
- Arr = Array("白色", 255, 255, 255, "黑色", 0, 0, 0, "红色", 255, 0, 0, "绿色", 0, 255, 0, "蓝色", 0, 0, 255, "青色", 0, 255, 255, "紫色", 128, 0, 128, "灰色", 128, 128, 128, "黄色", 255, 255, 0, "镉黄", 255, 153, 18, "金黄", 255, 215, 0, "肉黄", 255, 125, 64, "粉黄", 255, 227, 132, "香蕉黄", 227, 207, 87, "黄绿色", 127, 255, 0, "青绿色", 64, 224, 208, "天蓝灰", 202, 235, 216, "象牙灰", 251, 255, 242, "亚麻灰", 250, 240, 230, "杏仁灰", 255, 235, 205, "贝壳灰", 255, 245, 238, "棕褐色", 210, 180, 140, "古董白", 250, 235, 215, "浅绿色", 175, 238, 238, "海蓝色", 127, 255, 212, "蔚蓝色", 240, 255, 255, "米色", 245, 245, 220, "橘黄色", 255, 228, 196, "白杏仁", 255, 235, 205)
- For ii = 0 To UBound(Arr)
- If Arr(ii) = Str Then
- RetuColorRGB = RGB(Arr(ii + 1), Arr(ii + 2), Arr(ii + 3))
- Exit Function
- End If
- Next ii
- End Function
- Sub l2()
- Dim ColorArr
- ColorArr = Array("白色", "黑色", "红色", "绿色", "蓝色", "青色", "紫色", "灰色", "黄色", "镉黄", "金黄", "肉黄", "粉黄", "香蕉黄", "黄绿色", "青绿色", "天蓝灰", "象牙灰", "亚麻灰", "杏仁灰", "贝壳灰", "棕褐色", "古董白", "浅绿色", "海蓝色", "蔚蓝色", "米色", "橘黄色", "白杏仁")
- Dim Pres As Presentation
- Set Pres = Application.ActivePresentation
- Dim Sld As Slide
- Dim Shp As Shape
- Dim xx, yy
- Dim ii, jj, Kk As Integer
- Set Sld = Pres.Slides(1)
- Dim I, RGBValue
- '
- For ii = Sld.Shapes.Count To 1 Step -1
- Set Shp = Sld.Shapes(ii)
- Shp.Delete
- Next ii
-
- I = 100
- yy = 15
- With Sld
- With .Shapes
-
- For ii = 1 To 10
- xx = 2
- For jj = 1 To 9
- Set Shp = .AddShape(msoShapeRectangle, xx, yy, 75, 45)
- If Kk >= 28 Then
- Kk = 0
- End If
- Kk = Kk + 1
- With Shp
- .Fill.ForeColor.RGB = RetuColorRGB(ColorArr(Kk))
- .TextFrame2.TextRange.Text = ColorArr(Kk)
- .TextFrame.TextRange.Font.Color.RGB = RGB(0, 0, 0) ' RetuColorRGB(ColorArr("黑色"))
- End With
- xx = xx + 80
- Next
- yy = yy + 50
- Next ii
- End With
- End With
- End Sub
复制代码
|