Consulting

Results 1 to 10 of 10

Thread: Automating shadows

  1. #1

    Automating shadows

    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?



    Rudy Stricklan

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Is the shadow appearing on the shape or on text?

    Which version?
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    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

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    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
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  5. #5
    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

    Quote Originally Posted by John Wilson
    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

  6. #6

    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.


    Quote Originally Posted by rstricklan
    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

  7. #7
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Yes I can now repro! Looking into it.

    As a workaround this seems to work:

    [VBA]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[/VBA]
    Last edited by John Wilson; 02-12-2012 at 10:06 AM.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  8. #8
    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

    Quote Originally Posted by John Wilson
    Yes I can now repro! Looking into it.

    As a workaround this seems to work:

    [vba]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[/vba]

  9. #9
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    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!
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  10. #10
    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

    Quote Originally Posted by John Wilson
    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •