Shape Text that is attached to User Field evaluates to "question mark" = ?

Started by nemmas, February 23, 2015, 02:27:54 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


Hello All,

I'm new to this forum as a member but as a guest learned a lot from posts and articles here, so thank you for it.
For my problem...
I was under the impression I finally nailed my first ever ShapeSheet manipulation attempt, but I have a problem I could not find a solution for.

I have a custom container (called ToggleModule in my custom stencil).
The container has Shape Data assigned to it which are Layer, Module and Details, all strings. It also has a Fixed List as ToggleTag (the value of which is either Layer, Details or Module).
I have a User Row (User.MyShapeText) in ShapeSheet for the container to get the value of the fixed list and based on that read the pertaining Shape Data's (Layer, Details, Module) information.

Then I press F2 on the Container's text and Insert a field as =User.MyShapeText.
It all works fine, the correct text appears on the Container, my Shape Sheet functions read the right values from the Shape Data fields. I was very happy and proud of myself. :)

Side note:
This logic is needed for the following: the user is asked to define the Layer, Module or Details "tag" when she drops the shape and select which of the three tag types this shape should "toggle" in the future. Kind of a custom checkbox, which can control 3 different things based on the selection in the Fixed List. Then the container's text is derived automatically from the values entered and selection made and the user does not need to update the shape text manually to reflect the Shape Data entries entered upon drop.

The problem is: when I try to programmatically read (via VBA) the Shape's text field (vsoShape.Text) it evaluates to "?". I checked it in the debugger and it shows the same thing.

Any idea why this is happening? Is this a limitation?

Thank you


What's your code to read the text?

Are you trying to read the user cell, or trying to read the shapetext?

Visio 2019 Pro


Thanks for looking into this.

Whichever I read it evaluates to a "?", but I'm shooting for the Shape's text.
My code is as simple as "vsoShape.Text" and it evaluates to "?". Both if I print the value with MsgBox or Debug.Print or check it in the Debugger.
You can probably reproduce too easily.

Drop a regular container to the page. Edit its text and assign an arbitrary User Cell (e.g. User.visVersion or any) of the container to it. On the page the container's text will show appropriately, while in the Debugger or in Code you check the value of vsoShape.Text, a "?" will display.

For Each vsoShape In Visio.ActivePage.Shapes
MsgBox vsoShape.Text '---> will show "?"


Sorry, forgot to mention, that for now I worked around it with some code, which solution I don't like. :) I wanted to solve this in ShapeSheet 100%. Practically, instead of assigning the MyShapeText user field to the Shape's Text I set it using CallThis and Dependson via a VBA function.

Going back to the original, 100% ShapeSheet solution.
These are the fields I created for the container's subshape(2) i.e. the little header shape.

User.MyShapeText ="SET "&User.TagType&" - "&IF(STRSAME(User.Tag,""),"<Tag>",User.Tag)
User.TagType =IF(STRSAME(User.Tag,""),"<TagType>",Sheet.5!Prop.vsoToggleTag)
User.Tag = IF(STRSAME(Sheet.5!Prop.vsoToggleTag,"Layer"),Sheet.5!Prop.vsoLayerTag,IF(STRSAME(Sheet.5!Prop.vsoToggleTag,"Module"),Sheet.5!Prop.vsoModuleTag,IF(STRSAME(Sheet.5!Prop.vsoToggleTag,"Details"),Sheet.5!Prop.vsoDetailsTag,"NONE")))

For example, if the container's Prop.vsoToggleTag reads "Layer" and the Prop.vsoLayerTag has the value of "Layer 1" then the text will read "SET Layer - Layer 1". This display's perfectly on the "canvas" but not when reading vsoShape.Text in VBA. I get "?" instead.

Now going back to the workaround: I also assigned a MyShapeText user field to the container's main shape which look as:
User.MyShapeText =DEPENDSON(Sheet.230!User.MyShapeText)+CALLTHIS("Common_Logic.SetShapeText",,Sheet.230!User.MyShapeText)
Note: Sheet.230 is the subshape(2), the one I detailed above.

This is the subroutine CALLTHIS calls, pretty basic.
Public Sub SetShapeText(ByRef vsoShape As Visio.Shape, ByVal strText As String)
    vsoShape.Text = strText
End Sub


Reading shapetext directly involves something like:

Dim vsoShape As Visio.Shape
Dim vsoText As Visio.Characters

set vsoText = vsoShape.characters
msgbox vsoText

Yeah.  Weird.

Visio 2019 Pro


So were you able to reproduce it? That is, see it fine on the page but get "?" in code.

I think I'll live with my CALLTHIS workaround unless somebody can figure this out.

Thank you



I missed the fact that you posted again before my last answer...which was directed at your macro attempt.  The "Weird" comment was directed at having to use "characters" instead of what you attempted.  In VBA, to get the shapetext, you have to use the ---.characters.

So, no, I haven't tried to reproduce your scenario because:  1) I knew it would fail using VBA, and 2) you talk about "containers" which is V2010 or later, and I've chosen to stay at V2007.

But, the direct way to assign the "user text", would be to select the shape, go to insert field (wherever that may be on the ribbon...perhaps developer???), then you ought to be able select User.MyShapeText. 

Visio 2019 Pro


Sorry, I haven't visited back for a while.
I did attach a [Field] to the User.MyShapeText cell and that is what produces the question mark "?" output when querying vsoShape.Text in code. I'll try your Characters way and come back. In the last week I've stayed with the CALLTHIS approach I had outlined.


Quote from: nemmas on February 27, 2015, 08:58:36 PM
Sorry, I haven't visited back for a while.
I did attach a [Field] to the User.MyShapeText cell and that is what produces the question mark "?" output when querying vsoShape.Text in code. I'll try your Characters way and come back. In the last week I've stayed with the CALLTHIS approach I had outlined.

If there are any field values then Shape.Text will not capture those; hence the need to use Shape.Characters instead. At least this has been my experience with V2010 and V2013. I have to do this for any shape that I use field.values to set portions of text for; which I use for nearly everything in my documents.