EventDblClick = OPENTEXTWIN() but then for the text of a subshape

Started by Visisthebest, February 11, 2020, 05:38:28 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Visisthebest

Can the EventDblClick for a group shape be set so that the users edits the text of a specific subshape we specify in the shapesheet?

Kind of like EventDblClick = OPENTEXTWIN() but then for the text of a subshape.

Thank you for your help!
Visio 2021 Professional

Yacine

Not as specific as you want, but if you protect the group against text editing, then the first shape in the depth order of the group gets its text edited when pressing F2 (text edit). Not sure if the double click works as well.
Yacine

Visisthebest

Thank you Yacine that is already better than how it currently works!

Is it possible to open user editing of text on a (sub)shape with a macro? Then I could activate the macro when the group is double-clicked!
Visio 2021 Professional

Visisthebest

Turned on protection of the group text then getting this message when clicking the group and then F2:
Shape protection, container and/or layer properties prevent complete execution of this command.

Selecting the specific subshape and pressing F2 does still work properly.

Using Visio 2019.

Visio 2021 Professional

Visisthebest

Just making the subshape the frontmost shape seems to have done the trick though, no text protection on the group needed!
Visio 2021 Professional

vojo

since shapes grouped (shape relationship predefined), you can do something different

overview
- at group level, add controls to manage group shape properties
    - props.A for <for child shape A>
    - props.B fpr <for child shape B>
- use this to set text for each child  (group doubleclk = docmd(1312) or standard shape props window)
- then have each child shape pick the right value from group
    - use the fields function in each child shape to show its respective text.

Perhaps a simpler approach would be to go to behavior and set "show child shapes first" on the lower right of the menu
This would allow you to double click the child shape of interest.   From there you can use props  (docmd(1312) in eventdblclk)
or child shape data window to get user data into the shape....then either show the shape data on its screen or use fields to show in shape

The key problem with what you are trying to do is that the child shape has to be selected and double click to execute
Unless you want to write some VBA to achieve your results.

Visisthebest

Thank you Vojo! Unfortunately it will typically be multi-line text for which the shape data editor window isn't great being single line. How do you think I could solve it in VBA?

What you propose above is a great solution for another shape I'm working on though!
Visio 2021 Professional

vojo

I don't do much with VBA because the user has to set up his system to support

That said
- need to find the group on the page then find the shape in the group
- need to build a GUI or forms to get data
- need to place data in the shape

I think VBA will be over kill and be a security issue roadblock

May be could look at containers in visio....maybe a container of shapes where you can edit each shape directly

Visisthebest

Yes that becomes too complicated as well, maybe I should be using the group text and then align this text with the subshape I want this text to be shown on (disabling the text on the subshape itself). Bit of a workaround too though, but good to know there is some compromise necessary for this to work.

For the security issues putting a code signing certificate on the vba helps to mitigate that issue.

Thank you for your help and advice Vojo!
Visio 2021 Professional

vojo

RE certificate, sure...but only half the problem
Need to enable the VBA engine as well as VBA projects.  On excel projects I have done, those were beyond certificate stuff

Also, you cant guarantee all users have certificates....can you? 
They would have to change their security settings to allow VBA as well...at least had to do that for Excel

RE multiline:  You may want to play around to see if truly a problem (wrapping a long string, multiple prop fields, etc)

Croc

You can try a construction similar to this.
EventDblClick=SETF(GetRef(Sheet.4!Scratch.B1),"OPENTEXTWIN()")
Let Doubleclick pass Opentextwin() function to the subshape.

Or you can use the backlink from the subshape inside the Dependson() function
[Group].EventDblClick=Now()
[SubShape].Scratch.A1=OPENTEXTWIN()+DEPENDSON([Group]!EventDblClick)

Visisthebest

Thank you Croc will try these options for sure and let you know if I get them to work properly!
Visio 2021 Professional

Visisthebest

Croc this works really well!

EventDblClick=SETF(GetRef(Sheet.4!Scratch.B1),"OPENTEXTWIN()")

So writing to the Scratch section (I added it) is a trick to get in to text editing the subshape I assume?
Visio 2021 Professional

Croc

Yes. Visio performs the function at the time of recording. In this case, the function works in the context of the desired shape.

Visisthebest

Visio 2021 Professional