Jamie Garroch (MVP)
asked on
VBA value check not working for .Fill.Transparency in PowerPoint 2013
This is weird and driving me nuts.
If I open PowerPoint and add a rectangle to a slide, set its transparency to 10% via the PowerPoint UI (Format Shape pane) and then do this in the VBE immediate window while the shape is selected:
I see the expected result of 0.1
But what is going on here?
The transparency property returns a value of type Single so I tried these:
And weirdly this works:
I then tried this:
So why is 10% not equal to 0.1?
If I open PowerPoint and add a rectangle to a slide, set its transparency to 10% via the PowerPoint UI (Format Shape pane) and then do this in the VBE immediate window while the shape is selected:
?ActiveWindow.Selection.ShapeRange(1).Fill.Transparency
0.1
I see the expected result of 0.1
But what is going on here?
?ActiveWindow.Selection.ShapeRange(1).Fill.Transparency=0.1
False
The transparency property returns a value of type Single so I tried these:
?ActiveWindow.Selection.ShapeRange(1).Fill.Transparency=0.1!
False
?ActiveWindow.Selection.ShapeRange(1).Fill.Transparency=CSng(0.1)
False
And weirdly this works:
?Val(ActiveWindow.Selection.ShapeRange(1).Fill.Transparency)=0.1
True
I then tried this:
?ActiveWindow.Selection.ShapeRange(1).Fill.Transparency*100000
1000000.23841858
So why is 10% not equal to 0.1?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.