PP2007 Bug: HasChildShapeRange Not -1 If True

G

Guest

Although HasChildShapeRange is listed as boolean in the object browser, when
HasChildShapeRange is True, its value is 1, not -1. Consequently, IF
statements may not work as expected.

To illustrate the problem, put a couple of shapes on a slide and group them,
then select one of the group. That makes HasChildShapeRange true.
(ChildShapeRange returns the members of a group that are selected.) Insert
the following into a module, and run it:

Sub Play()
With ActiveWindow.Selection
If .HasChildShapeRange Then
Debug.Print "Yes"
Else
Debug.Print "No"
End If
If .HasChildShapeRange = True Then
Debug.Print "Yes"
Else
Debug.Print "No"
End If
If .HasChildShapeRange = False Then
Debug.Print "No"
Else
Debug.Print "Yes"
End If
If Not .HasChildShapeRange Then
Debug.Print "No"
Else
Debug.Print "Yes"
End If
End With
End Sub

Because HasChildShapeRange is true, the expected output would be Yes, Yes,
No, No, but the actual output is Yes, No, Yes, No. The expression
"If .HasChildShapeRange = True Then"
evaluates as false because 1 is not equal to -1 (the value of True). The
expression
"If Not .HasChildShapeRange Then"
always evaluates as True. (If HasChildShapeRange is False, it equals 0;
"Not 0" is -1, or True. If HasChildShapeRange is True, it equals 1; "Not 1"
is also True. Only "Not -1" is 0, or False.)

Recommendation:
Use "If .HasChildShapeRange Then" to test if the expression is True.
Use "If .HasChildShapeRange = False Then" to test if it is False.

Chris
 
G

Guest

Steve,
Thanks for the feedback.
I've decided to start reporting bugs when I find them. Maybe make it
easier on some else.

Chris
 
S

Steve Rindsberg

But at least we can be thankful for small favors: consistency.
It's dopey in 2003 as well.

Thanks for the thorough report. I've replicated here and will pass it along.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top