1

I have a shape in Visio which is a group. The group shape can have its text edited, and when it's edited I want one of the child shapes to sit just to the right of the text in the group shape.

To do this, I created a VBA function that takes the group shape as an argument, and this gets called in the TextText event on the shapesheet.

So the routine simply calls BoundingBox(visBBoxUprightText) on the group shape to get the bounds of the text and locate the sub shape to the right of the bbox. But the bounds appear to be wrong. They're coming back sometimes well to the left or well to the right of the last character.

Is the visBBoxUprightText flag supposed to mean something other than getting rectangle coordinates around the rendered text characters?

EDIT: Looking into it some more, I see that the BoundingBox method looks at the shape.type property to determine what the boundingbox encloses. If the shape type is visGroup then it's going to include the sub shapes as well, and there doesn't seem to be a flag to force it to consider the group as a simple shape.

So I guess now the question is, is there a way to get the BoundingBox of the text, ignoring sub-shapes? I tried putting a separate sub-shape to hold the text, and now it works like a charm.

Jon Fournier
  • 4,089
  • 3
  • 30
  • 41
  • Looking at it further, it seems to be closer to correct when the sub shape doesn't have text. So I wonder if I have to somehow specify only the parent shape, not the sub shape. Or, alternatively, force the text to be in a sub shape, rather than the group shape – Jon Fournier Jun 27 '12 at 13:27
  • Jon, you may want to look at implementing this functionally using shapesheet formulas which make use of the TEXTWIDTH shapesheet function. –  Jun 28 '12 at 19:59
  • Thanks @PatLeahy I did do that a few days ago, but I left the question up to make sure there's a way to deal with the group thing, though I guess it's probably not a very common thing to need. – Jon Fournier Jun 29 '12 at 15:19

1 Answers1

0

Visio does not let you get the bounding box of the text while disregarding the text of sub-shapes in a grouped shape.

Jon Fournier
  • 4,089
  • 3
  • 30
  • 41