Defeated coder

W

Wicked Wizard

I need a little bit of code you'd think was dead simple but I cannot make it
work...

WinXP Pro, PPT 2000

I want to create some shapes on a page at the touch of a button.

The macro reads:

Sub addSomeShapes()

Dim leftPosition As Single
Dim topPosition As Single
Dim width As Single
Dim height As Single
Dim i As Integer

leftPosition = 130
topPosition = 250
width = 50
height = 50
i = 1

For i = 1 To 4

ActivePresentation.Slides(4).Shapes.AddShape(msoShape5pointStar,
leftPosition, topPosition, width, height).Fill.ForeColor.RGB = RGB(128, 0,
0)
leftPosition = leftPosition + 125

Next i

End Sub

I get the shapes, but I do not get the fill colour. I've tried creating the
shapes, selecting them and setting colour, with no luck. I have battled it
for nearly 2 hrs and now need a little help.

Incidentally I always get trouble using RGB values.

On another slide I have a shape and change the fill but always have to use
vbRed, etc rather than RGB values. So I know I've not got hold of
someething properly. But in the example above neither solution works.

PLEASE!

WW
 
S

Shyam Pillai

It's possible that the fill color is not visible in the default shape
associated with the slide. So force the fill to be visible. The code below
will resolve both your issues.

With ActivePresentation.Slides(1).Shapes.AddShape(msoShape5pointStar,
leftPosition, topPosition, width, height)
.Fill.ForeColor.RGB = RGB(128, 0, 0)
.Fill.Visible = True
.Fill.Solid
.Fill.Transparency = 0#
.Fill.Visible = True
End With
 
W

Wicked Wizard

Thank you Shyam.

Shyam Pillai said:
It's possible that the fill color is not visible in the default shape
associated with the slide. So force the fill to be visible. The code below
will resolve both your issues.

With ActivePresentation.Slides(1).Shapes.AddShape(msoShape5pointStar,
leftPosition, topPosition, width, height)
.Fill.ForeColor.RGB = RGB(128, 0, 0)
.Fill.Visible = True
.Fill.Solid
.Fill.Transparency = 0#
.Fill.Visible = True
End With


--
Regards,
Shyam Pillai

Toolbox: http://skp.mvps.org/toolbox
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top