• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 252
  • Last Modified:

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:


Open in new window

I see the expected result of 0.1

But what is going on here?


Open in new window

The transparency property returns a value of type Single so I tried these:


Open in new window

And weirdly this works:

Open in new window

I then tried this:

Open in new window

So why is 10% not equal to 0.1?
Jamie Garroch
Jamie Garroch
2 Solutions
Dale FyeCommented:
because that value is stored as double precision, which tends to contain rounding errors.

Keep in mind, that all number (including decimals) are represented as 0's and 1's.  I've never really understood how the decimals are handled but Access does not store the value of 0.1, it stores a binary representation of that number.  Whenever I need to compare two numbers, one of which is a decimal, I usually do something like:

?Abs(ActiveWindow.Selection.ShapeRange(1).Fill.Transparency - 0.1) < 0.0001
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now