getting data from another shape

Started by KKAiii, February 21, 2018, 01:47:09 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

KKAiii

In a sub-shape I am trying to get data from another shape.
I have successfully used the following syntax in a shape [not a sub-shape] to get data from another [source] shape:
        SourceShapeName!SourceUserDefinedCell.
But this syntax does not work when I attempt to use it in a shape that is in sub-group.
Is there a modification to the callout's syntax that will make it work?

vojo

works for me

shape 1 = subshape 1 = sheet.1
shape 2 = sushape 2 = sheet.2
shape 3 = group of shape 1 and shape 2 = sheet.3

user.shape 2 = "this is shape 2"
user.shape1 = sheet.2!user.shape 2 = "this is shape 2"

works for me...multiple drops of the group work....use it all the time for 10 years.
Visio will recalculate....sheet.2!user.shape2...becomes... sheet.5!user.shape 2

Now a problem comes in when you think about the following
1 drop the group
2 drop another group
3 Now drop some sort of external to the group source shape

<other way around doesn't work either>

How do you find the source shape?   what if I drop a 3rd group before source shape? how do I find it.
Well, visio doesn't support any sort "discover" of source shape.   It wont try to find the source shape by ID or user created handle.

for that you need VBA

Basically, the relationships are static and within the group...otherwise VBA or manually update shapesheets.

If you really want to access an unrelated shape (not in the group), you can do the following but gets tedious quickly
1) create user cell(s) in the page shapesheet.
2) arbitrary source sheet pushes a value into page!user.msg cell....setf(getref(page!user.zmsg), "I am source shape z")
3) sink shapes access the page user cell(s).....page!user.zmg

Limit are 1 source shape per role
(source shapes for X function uses page!user.xmsg...source shapes for Y function uses page!user.ymsg)
Otherwise need VBA because 2 source shapes would have figure out which page!user cell to place their msg and sink shapes would need to figure out which source shape to use.


KKAiii

VoJo, Thank you so very much for reading and responding to my post.
I was able to duplicate your example successfully.
In it you were linking [importing, getting, whatever] data between two sub-shapes that were in the same group.
While I did not make it clear, I was trying to link data between a sub-shape and a shape that was external to the sub-shape's group. Initially I failed as had all my other attempts in my real life task.
I compared my formula for the link to my external shape [ExternalShape!User.ExternalShape] with my successful formula for linking to data in the other sub-shape [Sheet.2!User.Sheet2]. The only thing I could see that made them significantly different was the name of the source shape. Specifically in the successful link the name was that assigned by VISIO [Sheet.2!User.Sheet2]. While in the unsuccessful link the name was one I had assigned via Developer/Shape Name/Name [ExternalShape!User.ExternalShape]. Amazingly [To me at any rate] when I changed "ExternalShape" to "Sheet.8" [VISIO's name for the shape] the formula that previously failed now worked!!!!
Conclusion: In the formula [ShapeName!ShapecellName] you CANNOT use a name you assign to a shape you MUST use the name VISIO assigns, i.e. it will be "Sheet.#" where # is whatever number VISIO has assigned.
Again, thank you for responding.

Surrogate

#3
Quote from: KKAiii on February 22, 2018, 02:48:14 PM
Conclusion: In the formula [ShapeName!ShapecellName] you CANNOT use a name you assign to a shape you MUST use the name VISIO assigns, i.e. it will be "Sheet.#" where # is whatever number VISIO has assigned.
hope this link can explain why, better use universal (sheet.<xx>) names!

AnotherNoOne

Otherwise you could always make your shapedata global by using Setf and getref to set a user defined cell in TheDoc...

(wil become a catastrophe though when you have many different shapes and formulas, for small drawings it would work)
Another_Noone

Just some weirdo on the Interwebs.

KKAiii

Browsing the web I see that my statement that you "cannot" use the user assigned name for a referenced shape is not quite correct. There are situations where you can, e.g. between shapes that are "peers", i.e. are at the same level regarding where they are, in or not in, a group. I prefer minimizing the rules I have to remember [cause I'll get'm wrong!] so I will simply always use the "Sheet.ID#' format for a referenced shape's name in the formula ShapeName!ReferencedCellName.