Folks:
I’ve been using this articulated line for a few years now, and it’s worked reasonably well. But I don’t like how the bounding box looks. So my immediate goal is to have the box tight around the segments.
I'd prefer a DOCMD shapesheet solution to reset the box, but I couldn't locate one. However, I was able to do it by adding the following code:
Sub ResetAlignmentBox(TheShape As Shape)
TheShape.UpdateAlignmentBox
End Sub
I call the code by putting the following into its own user cell in the group-level shape:
=CALLTHIS("ThisDocument.ResetAlignmentBox","Tracer")+DEPENDSON(NOW())
‘ “Tracer” is the name of my stencil where the code resides
Whenever you move the line segments around, it fires and re-sizes the alignment box as expected. Yes, it does re-size the box once every minute as well, but I can live with that. Maybe. Read on...
All that said, this solution is not my preferred solution; it’s just a hack that gets me close. What I really want is for the DEPENDSON to depend on the Width cell in any one of the group’s subshapes. But I can’t figure out how to reference the subshape’s Width cell from within the grouped shape's shapesheet. You think it’d be a straightforward Sheet.nn!Width, but that keeps on giving me an error. What am I doing wrong?
Getting back to the DEPENDSON(NOW()), it likes to fire at odd times, not just once a minute. One of those odd times is when I save the master shape. The first time I try to save the shape Visio gives me an error, but the second time it saves it fine. But then when I save the stencil, Visio does the saving, but it still thinks the stencil is unsaved. Because the DEPENDSON fires whenever you save it? Beats me. All I know is I want the subshape Width reference there, not the NOW().
Always something!
- Ken
Vojo:
Not sure I understand what you’re suggesting. All I want is for the alignment box to show, and to automatically adjust whenever I move the line segments around. I used your DOCMD in place of NOW(), but it repeatedly asked me if I wanted to define user data. Not what I was looking for.
Wapper-man:
Not sure I understand you either. Setting UpdateAlignBox to True did nothing. I did it in all the segments and the group, with and without NoAlignBox, but the box doesn’t cling to the segments.
To reiterate: My goal is to have the alignment box cling tightly to the line segments. Ideally, I want to change...
=CALLTHIS("ThisDocument.ResetAlignmentBox","Tracer")+DEPENDSON(NOW())
...to say...
=CALLTHIS("ThisDocument.ResetAlignmentBox","Tracer")+DEPENDSON(SubshapeOne!Width)+DEPENDSON(SubshapeTwo!Width)+DEPENDSON(SubshapeThree!Width)
...but I don’t know how to access “”SubshapeOne!Width” from the grouped shape. Or SubshapeTwo and SubshapeThree, for that matter.
It turns out it doesn't matter, because I DO know how to access the group shape from the subshapes. So I turned the problem around. In the grouped shape (Sheet.17 in this example), I added three User section rows, SubshapeOne, SubshapeTwo, and SubshapeThree. I added a fourth row that says:
=CALLTHIS("ThisDocument.ResetAlignmentBox","Tracer")+DEPENDSON(User.SubshapeOne)+DEPENDSON(User.SubshapeTwo)+DEPENDSON(User.SubshapeThree)
Lastly, in the first subshape, I added a User.Cell with =SETF(GetRef(Sheet.17!User.SubshapeOne),Width), then SubshapeTwo and SubshapeThree, respectively.
That did it. Whenever any of the line segment lengths change, the new width is reflected on the grouped shape’s user cell, and that user cell is used to trigger the DEPPENDSON. Problem solved.
Thanks again for the help!
- Ken