Powerpoint宏/第二色中的两种颜色渐变保持白色

时间:2018-02-14 16:47:08

标签: vba powerpoint gradient powerpoint-vba

尝试在powerpoint宏中创建2色渐变。第二种颜色不断显示为白色。我在这里看到了另一个关于同样问题的问题,但答案对我没有用。谁能发现我的问题?提前谢谢!

Dim Sld As Slide
Dim Shp As Shape

Set Sld = Application.ActiveWindow.View.Slide

'TIMELINE BOX
    Set Shp = Sld.Shapes.AddShape(Type:=msoShapeRectangle, _
        Left:=-5, Top:=0, Width:=365, Height:=50)

    'Shape Name
        Shp.Name = "DateBox1"
    'No Shape Border
        Shp.Line.Visible = msoTrue
        Shp.Line.Weight = 2
        Shp.Line.ForeColor.RGB = RGB(255, 255, 255)
    'Shape Fill Color
        Shp.Fill.Visible = msoTrue
        Shp.Fill.ForeColor.RGB = RGB(18, 115, 57)
        Shp.Fill.BackColor.RGB = RGB(72, 166, 105)
        Shp.Fill.TwoColorGradient msoGradientHorizontal, 2
        'Shp.Fill.GradientStops.Item(1).Position = 50
        Shp.Fill.RotateWithObject = msoTrue

    'Shape Text Color
        Shp.TextFrame.TextRange.Font.Color.RGB = RGB(255, 255, 255)
    'Text inside Shape
        Shp.TextFrame.TextRange.Characters.Text = "DATE"
    'Center Align Text
        Shp.TextFrame.TextRange.Paragraphs.ParagraphFormat.Alignment = ppAlignCenter
    'Vertically Align Text to Middle
        Shp.TextFrame2.VerticalAnchor = msoAnchorMiddle
    'Adjust Font Size
        Shp.TextFrame2.TextRange.Font.Size = 22
        Shp.TextFrame2.TextRange.Font.Name = "Myriad Pro"
        Shp.TextFrame2.TextRange.Font.Bold = True
        Shp.TextFrame2.TextRange.Font.Shadow.Type = msoShadow1
        Shp.TextFrame2.TextRange.Font.Shadow.OffsetX = 10
        Shp.TextFrame2.TextRange.Font.Shadow.OffsetY = 10
        Shp.TextFrame2.TextRange.Font.Shadow.Size = 1
        Shp.TextFrame2.TextRange.Font.Shadow.Blur = 4
        Shp.TextFrame2.TextRange.Font.Shadow.Transparency = 0.5
        Shp.TextFrame2.TextRange.Font.Shadow.Visible = True
  'Shadow
    Shp.Shadow.Type = msoShadow1
    Shp.Shadow.ForeColor.RGB = RGB(0, 0, 0)
    Shp.Shadow.Transparency = 0.7
    Shp.Shadow.OffsetX = 2
    Shp.Shadow.OffsetY = 2
    Shp.Shadow.Blur = 60

1 个答案:

答案 0 :(得分:0)

首先设置渐变填充,然后设置颜色:

Shp.Fill.TwoColorGradient msoGradientHorizontal, 2
Shp.Fill.ForeColor.RGB = RGB(18, 115, 57)
Shp.Fill.BackColor.RGB = RGB(72, 166, 105)