PDA

View Full Version : Automating shadows



rstricklan
02-08-2012, 11:27 AM
You'd think this would be really easy. I want to select one or more shapes, and add a drop shadow with my choice of parameters. Here's the VBA code:

Sub MakeShadow5()
With ActiveWindow.Selection.ShapeRange.Shadow
.ForeColor.RGB = RGB(0, 0, 0)
.Transparency = 0
.Visible = True
.Blur = 5
.OffsetX = 5
.OffsetY = 5

End With
End Sub

What I end up with most of the time is a shadow that is light gray instead of the black (RGB 0,0,0) that I want. Under certain conditions, the macro works fine and the shadow color is black-- but I have no idea why it works sometimes and not others. Thoughts from the experts out there?

:banghead:

Rudy Stricklan

John Wilson
02-08-2012, 01:36 PM
Is the shadow appearing on the shape or on text?

Which version?

rstricklan
02-08-2012, 01:45 PM
Hi John--

Yes, it would be good to have included more details :-)

It's PP 2010, and the issue is with geometric shapes, not text.

Thanks for the speedy response!

Rudy Stricklan

John Wilson
02-08-2012, 02:07 PM
No, I cannot repro that. I always get black (obviously some grey because of the blur but mainly black)

can you post an example somewhere or if you like mail it
john AT pptalchemy.co.uk

rstricklan
02-08-2012, 04:24 PM
Now I can't get it to fail, John. It must know that you're on the case :-). Once I get a solidly-failing example, I'll send it up. Thank you again for looking into this for me.

Rudy Stricklan


No, I cannot repro that. I always get black (obviously some grey because of the blur but mainly black)

can you post an example somewhere or if you like mail it
john AT pptalchemy.co.uk

rstricklan
02-11-2012, 02:02 PM
John, I think I finally nailed down when my shadow settingsmacro fails reliably. If I copy and paste in an image (as either a Paste(P) ora Paste(U) operation), then the shadow color is inevitably light gray. However,if I save the clipboard to an image file, then the resulting image shadow colorwill be black as I want.

Apparently images placed by a paste operation havetheir forecolor controlled differently…?



Thanks for any thoughts that you may have on this latesttwist—I also posted this to the forum so others can see it.



Now I can't get it to fail, John. It must know that you're on the case :-). Once I get a solidly-failing example, I'll send it up. Thank you again for looking into this for me.

Rudy Stricklan

John Wilson
02-12-2012, 09:34 AM
Yes I can now repro! Looking into it.

As a workaround this seems to work:

Sub MakeShadow5()
Dim i As Integer
With ActiveWindow.Selection.ShapeRange.Shadow
For i = 1 To 2
.ForeColor.RGB = RGB(0, 0, 0)
.Transparency = 0
.Visible = True
.Blur = 5
.OffsetX = 5
.OffsetY = 5
Next i
End With
End Sub

rstricklan
02-12-2012, 10:23 AM
That is weird, that introducing a do loop seems to have an effect. Sort of like the old FORTRAN days when just putting in a delay loop would fix up those problems that no amount of logic could remedy :-).

Thank you, John-- let me know when you've cracked it!

Rudy Stricklan


Yes I can now repro! Looking into it.

As a workaround this seems to work:

Sub MakeShadow5()
Dim i As Integer
With ActiveWindow.Selection.ShapeRange.Shadow
For i = 1 To 2
.ForeColor.RGB = RGB(0, 0, 0)
.Transparency = 0
.Visible = True
.Blur = 5
.OffsetX = 5
.OffsetY = 5
Next i
End With
End Sub

John Wilson
02-12-2012, 10:56 AM
It is weird but you can see the same effect if you add the shadow from the GUI.
Add it once - Grey
Add it again - Black!

rstricklan
02-12-2012, 11:18 AM
I see what your workaround codes does now, John. As far as I'm concerned, the problem's solved (at least for me)! But I bet it continues to bug you...

Rudy:beerchug:


It is weird but you can see the same effect if you add the shadow from the GUI.
Add it once - Grey
Add it again - Black!