Consulting

Results 1 to 10 of 10

Thread: Apply Artistic Effect to Current Selection / Create Button

  1. #1

    Apply Artistic Effect to Current Selection / Create Button

    Hello everyone,

    I'm trying to achieve a couple things that are related:

    Main issue:
    I want to write code so that when this function is run, the currently selected picture will have an artistic effect applied. This is the code I've tried to write for it, but I cannot get it to work. Note, this is not intended to be used during presentation mode, but normal mode.

    [VBA]Sub EdgeDefine()
    Dim myShape As Shape
    Dim myEffect As PictureEffect

    If ActiveWindow.Selection.Type = ppSelectionShapes Then
    Set myShape = ActiveWindow.Selection
    With myShape.Fill.PictureEffects
    If .Count > 0 Then
    .Delete (1)
    Else
    .Insert (msoEffectGlowEdges)
    End If
    End With
    End If
    End Sub
    [/VBA]

    My second problem (related), is I want to tie this macro to a custom button that I can put on the ribbon. What's the easiest/most efficient way how to accomplish this?

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    [VBA]Sub EdgeDefine()
    Dim myShape As Shape
    Dim myEffect As PictureEffect

    If ActiveWindow.Selection.Type = ppSelectionShapes Then
    Set myShape = ActiveWindow.Selection.ShapeRange(1)
    If myShape.Type = msoPicture Then
    With myShape.Fill.PictureEffects
    If .Count > 0 Then
    .Delete (1)
    Else
    .Insert (msoEffectGlowEdges)
    End If
    End With
    End If
    End If
    End Sub[/VBA]

    To add a custom button to the ribbon you should use XML
    There's a tutorial on the basics here
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    John,

    Thank you! It's frustrating that it only needed a slight change, but Powerpoint coding is fairly new to me. You rock!

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Download this

    Insert and select a Picture and look in Picture Tools Tab
    One advantage of using the Picture Tools tab is it will only show when a picture is selected.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  5. #5
    Bah.

    It works....

    But only on some images. Is there anything I can do to tell it to do any image, or how I can check the properties of my images so I can recode to check for it?

  6. #6
    To add additional information, I tried to copy two photos to my macro-enabled ppt so I could put a watch on the code.

    When I copied them over, code worked on both.
    Pre-copy, only one worked.

    ????

  7. #7
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    You are probably running into one of the little tests that 2007 on programmers built in to annoy you.

    If you have a picture in a placeholder 2007 thinks that the placeholder is the shape and therefor it's not a picture!

    You would need to query the contained type

    [VBA]Sub EdgeDefine()
    Dim myShape As Shape
    Dim myEffect As PictureEffect

    If ActiveWindow.Selection.Type = ppSelectionShapes Then
    Set myShape = ActiveWindow.Selection.ShapeRange(1)
    If myShape.Type = msoPlaceholder Then
    If myShape.PlaceholderFormat.ContainedType = msoPicture Then
    With myShape.Fill.PictureEffects
    If .Count > 0 Then
    .Delete (1)
    Else
    .Insert (msoEffectGlowEdges)
    End If
    End With
    End If
    End If
    If myShape.Type = msoPicture Then
    With myShape.Fill.PictureEffects
    If .Count > 0 Then
    .Delete (1)
    Else
    .Insert (msoEffectGlowEdges)
    End If
    End With
    End If
    End If
    End Sub
    [/VBA]

    If you use the example I uploaded you can delete all of the checks because if the Picture tools shows it IS a picture.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  8. #8
    I solved this. Basically, if you skip the validation of what kind of shape it is, and just try to apply the pictureeffect, then it will do it to every picture. My guess is that pasting a shape into a powerpoint inserts it as an image.

    Thank you to all who helped!

  9. #9
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    My guess is that you are copying a picture in a placeholder and pasting it outside.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  10. #10
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    Quote Originally Posted by John Wilson
    You are probably running into one of the little tests that 2007 on programmers built in to annoy you


    You must have cracked the code

    Paul

Posting Permissions

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