NickyC
07-27-2015, 11:06 PM
Hi
I am trying to use VBA to set a slide's background to vertical gradients of different colours. I can create a shape with gradients, but when I try to apply the code to the slide background I get a message saying gradients stops can only be accessed on shapes with gradient fill.
This is what I have tried. I am probably just missing one line of code, but can't work out what it is.
[Sub BackGradients()
Dim MyDoc As Slide, Col1, Col2, Col3, Col4
Set MyDoc = ActivePresentation.Slides(1)
Col1 = RGB(255, 0, 0) 'red
Col1 = RGB(0, 255, 0) 'green
Col1 = RGB(0, 0, 255) 'blue
Col1 = RGB(0, 255, 255) 'yellow
With MyDoc.Background.Fill
.GradientStops.Insert Col1, 0.25
.GradientStops.Insert Col2, 0.5
.GradientStops.Insert Col3, 0.75
End With
End Sub
I am trying to use VBA to set a slide's background to vertical gradients of different colours. I can create a shape with gradients, but when I try to apply the code to the slide background I get a message saying gradients stops can only be accessed on shapes with gradient fill.
This is what I have tried. I am probably just missing one line of code, but can't work out what it is.
[Sub BackGradients()
Dim MyDoc As Slide, Col1, Col2, Col3, Col4
Set MyDoc = ActivePresentation.Slides(1)
Col1 = RGB(255, 0, 0) 'red
Col1 = RGB(0, 255, 0) 'green
Col1 = RGB(0, 0, 255) 'blue
Col1 = RGB(0, 255, 255) 'yellow
With MyDoc.Background.Fill
.GradientStops.Insert Col1, 0.25
.GradientStops.Insert Col2, 0.5
.GradientStops.Insert Col3, 0.75
End With
End Sub