PowerPoint 2007/2010 VBA code to change Type of Gradient Fill on a Shape object

我与影子孤独终老i 提交于 2019-12-13 01:35:02

问题


With PowerPoint 2007 & 2010, I have been trying to change the Type of Gradient Fill on a Shape object from default "Rectangular" to "Path" for days. Searched online but seems like no such question asked.

So far I can only get the Gradient Fill to be "Rectangle" (the default with 2 color gradient?). But I want it to be "Path". So far only able to do that by right click on the actual Shape --> Format Shape. "Format Shape" form shows and I can change the "Type:" from Rectangle to Path. But I want to do this change in VBA, anyone have a solution?

My code below. Variables starting with g are As Single

Set oSlide = ActivePresentation.Windows(1).View.Slide
    With oSlide.Shapes.AddShape(msoShapeIsoscelesTriangle, gLeft, gTop, gWidth, gHeight)
        .Line.Visible = msoFalse ' No Outline
        .Adjustments(1) = gAdj1 ' Adjust the position of the pointing tip
        .Rotation = gAngle ' Change the angle of Rotation
        .Fill.Visible = msoTrue
        .Fill.TwoColorGradient msoGradientFromCenter, 1     ' Enable Two Colour Gradient
        .Fill.GradientStops(1).Color.RGB = RGB(255,255,255) ' Colour at center
        .Fill.GradientStops(2).Color.RGB = RGB(121,121,121) ' Colour at edge
        .Select
    End With
Set oSlide = Nothing

If no VBA codes can achieve that, I will have to use workaround... Copy and Paste those Shapes from a Template file - this sounds bad as I am going to make it a PowerPoint AddIn.

Thanks in advance! Patrick

来源:https://stackoverflow.com/questions/17960260/powerpoint-2007-2010-vba-code-to-change-type-of-gradient-fill-on-a-shape-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!