Search code examples
applescriptpowerpoint

Set the fill of a shape to "No Fill" using AppleScript


I'd like to turn off the fill of a selected shape in PowerPoint using AppleScript.

  • I do not want to set the fill to white
  • I do not want to make the shape 100% transparent

I want remove the fill entirely as if I had selected the shape and clicked "No Fill" in the Shape Options panel.

I am able to manipulate the fill color and fill transparency using AppleScript, but not remove the fill entirely. A shape without a fill has the property fill format type:fill unset however that is a read-only property.

I've tried various methods of accessing the fill format type, including setting it to 'none' but to no avail. I am guessing setting the fill to none is not possible using AppleScript, but maybe there's some non-obvious way to do it.


Solution

  • Assuming that the specified shape is shape 4 of the active slide:

    tell application "Microsoft PowerPoint"
        set visible of fill format of shape 4 of slide 1 of active presentation to false    
    end tell
    

    This changed the value of the 'Color' dropdown on the 'Fill' tab of the 'Format Shape dialogue (Format > Shape…) to 'No Fill'.

    When set to 'true', the fill should return either to its previous state or to the default fill.