I think the main issue with your existing script is that the second [i] subscript should be outside of the parentheses:
dt = Open( "$SAMPLE_DATA/Ishikawa.jmp" );
obj = dt << Diagram( Y( :Child ), X( :Parent ) );
(obj << XPath("(//TextEditBox)"))[9] << Text Color("Red");
With a constant, you *can* put the subscript directly in the XPath expression:
dt = Open( "$SAMPLE_DATA/Ishikawa.jmp" );
obj = dt << Diagram( Y( :Child ), X( :Parent ) );
(obj << XPath("(//TextEditBox)[9]")) << Text Color("Red");
But in your case, it is really sending a <<Subscript(XPath(),i) message to the report. I am assuming that the subscript on your dgram[i] is intentional - do you have an array of Diagram objects?