Visio Guy

Visio Discussions => General Visio => Topic started by: Visisthebest on January 19, 2024, 04:38:29 PM

Title: Visio shape data / user cell in shape text with multiple colors other formatting
Post by: Visisthebest on January 19, 2024, 04:38:29 PM
I am trying to see if there is a way to bind multiple user cells and shape data cells to a single text box and this is possible no problem.

The next step is I am trying to see if I can apply different colors to the different texts now showing from these user cells / shape data cells in the same shape?

Say:
User.A with the word "Green"
User.B with the word "Orange"

where I can apply the color green to the word Green and the color orange to the word Orange.

I don't seem to be able to do this, but maybe there is a cool workaround I am not aware of, another way of achieving this with the shapesheet.
Title: Re: Visio shape data / user cell in shape text with multiple colors other formatting
Post by: Surrogate on January 19, 2024, 04:52:10 PM
Quote from: Visisthebest on January 19, 2024, 04:38:29 PM
Say:
User.A with the word "Green"
User.B with the word "Orange"
What is your purpose?
Title: Re: Visio shape data / user cell in shape text with multiple colors other formatting
Post by: wapperdude on January 19, 2024, 07:40:08 PM
Is this shapesheet only solution or is code allowed?
Title: Re: Visio shape data / user cell in shape text with multiple colors other formatting
Post by: Visisthebest on January 19, 2024, 11:14:57 PM
With the shapesheet, if this is possible.

The purpose is colorcoding data that is good, mediocre or bad.

Putting it in to one shape instead of several is for performance reasons, to avoid having too many shapes.

I don't think it is possible without programming, but I may be overlooking a clever workaround.
Title: Re: Visio shape data / user cell in shape text with multiple colors other formatting
Post by: Nikolay on January 20, 2024, 01:08:43 PM
If I understand you goal correctly, you could try to play with "character" section.
I would not do that though (may be fragile) but depends on your case of course.
A sample attached.
Title: Re: Visio shape data / user cell in shape text with multiple colors other formatting
Post by: Visisthebest on January 20, 2024, 04:15:50 PM
Amazing Nikolay :D I thought this was not possible how did you do this?

I am only able to add one text field row (where I then combine multiple User.X references in to a single string) but don't know how you can add multiple rows. In the shapesheet section I do not have an option to add a row like in the User section and other sections.

Also, where is the middle string "something" coming from?

Yes the characters section is a bit fragile, but I think I can work with the limitations.

One thing I also wondered, is there a string character code which does not take up any space (so I can add some invisible padding to keep the amount of characters the same in a coloured section in the text)?
Title: Re: Visio shape data / user cell in shape text with multiple colors other formatting
Post by: Nikolay on January 20, 2024, 05:06:06 PM
Well I just inserted two fields, "first" and "second" (using the "insert field" command). The text "something" is just a plain text between them. You can insert as many fields as you want, that's why the command is called "insert field". Then set the color of the first field to red and then the color of the second field also to red (using the "text color" command). This added two fragments to the "characters" section.  Then in the "characters" section I have sent the color for the first fragment to be equal to "first color" property and the color of the second fragment to be equal to the "second color" property.

A common confusion here is how you insert fields. To insert more than one, you need to enter the text edit mode (i.e. start edting text and then while in the text edit, insert the fields into it). Then field is inserted into the text at your current cursor position (it does not replace the text, but is inserted into it)

Here is a video where some guy inserts multiple fields: https://youtu.be/NXwqpDojdB8?si=JsaLDaL8uf-mPBrI&t=107
Title: Re: Visio shape data / user cell in shape text with multiple colors other formatting
Post by: wapperdude on January 20, 2024, 06:10:43 PM
Here are some related topics:
http://visguy.com/vgforum/index.php?topic=9180.msg40713#msg40713 (http://visguy.com/vgforum/index.php?topic=9180.msg40713#msg40713)
http://visguy.com/vgforum/index.php?topic=5678.msg22615#msg22615 (http://visguy.com/vgforum/index.php?topic=5678.msg22615#msg22615)
https://visualsignals.typepad.co.uk/vislog/2020/03/creating-a-visio-shape-with-an-expanding-row-count.html#more (https://visualsignals.typepad.co.uk/vislog/2020/03/creating-a-visio-shape-with-an-expanding-row-count.html#more)
http://visguy.com/vgforum/index.php?topic=9067.msg40108#msg40108 (http://visguy.com/vgforum/index.php?topic=9067.msg40108#msg40108)
http://visguy.com/vgforum/index.php?topic=8369.msg36203#msg36203 (http://visguy.com/vgforum/index.php?topic=8369.msg36203#msg36203)
http://visguy.com/vgforum/index.php?topic=7377.msg31046#msg31046 (http://visguy.com/vgforum/index.php?topic=7377.msg31046#msg31046)
Title: Re: Visio shape data / user cell in shape text with multiple colors other formatting
Post by: Visisthebest on January 20, 2024, 07:23:42 PM
Thank you Nikolay yet I just select the shape then add a field, did not realize I should edit the text then add a field!

Wapperdude thank you for all the links, what I am trying to achieve will not be simple so good to get a better understanding of the Characters section (and object in code) first this is very different from HTML text with tags for text color, bold etc.
Title: Re: Visio shape data / user cell in shape text with multiple colors other formatting
Post by: Visisthebest on January 20, 2024, 07:45:32 PM
Found this comment in one of your posts Wapperdude very interesting:

Note, it's possible to pass more than just text.  For example, the following would pass the result of the "Len" function:
        shp.Characters.AddCustomFieldU Chr(34) & Len("NewFieldText") & Chr(34), visFmtNumGenNoUnits

Adding 'fields' is basically adding in custom formulas that write part of the content of the text box very useful.
Title: Re: Visio shape data / user cell in shape text with multiple colors other formatting
Post by: Nikolay on January 21, 2024, 12:08:12 AM
Quote from: Visisthebest on January 20, 2024, 07:23:42 PM
Thank you Nikolay yet I just select the shape then add a field, did not realize I should edit the text then add a field!

Yes, this is exactly the confusion. Visio developers could have done something better here for the usability.
Anyway, after you add the fields this way, and then add some formatting to them (like I said before, you can select the field fragment while editing text and change the color for the field for example), you get that "characters" section you can control:

The "THEMEGUARD" is not really important, it's only relevant if you care for themes, the whole thing can be simplified to just a direct reference to the "color" property, like "Prop.FirstColor"
Title: Re: Visio shape data / user cell in shape text with multiple colors other formatting
Post by: Visisthebest on January 21, 2024, 10:09:52 AM
Thank you Nikolay, as far as I can understand from Wapperdude's linked posts and the macro recorder all this can be done from automation with code as well, or am I overlooking something not possible in code only in the UI possible?
Title: Re: Visio shape data / user cell in shape text with multiple colors other formatting
Post by: Nikolay on January 21, 2024, 03:16:16 PM
Hm I did not think how to do that with code tbh, I tried that using UI only.
Title: Re: Visio shape data / user cell in shape text with multiple colors other formatting
Post by: wapperdude on January 21, 2024, 06:49:11 PM
In reply #4, this link: http://visguy.com/vgforum/index.php?topic=5678.msg22615#msg22615 (http://visguy.com/vgforum/index.php?topic=5678.msg22615#msg22615), there is Visio file that has example of both standard shapetext and field inserted text.  Working with field text is somewhat more challenging than standard text.  The file provides an opportunity to explore both. 
Title: Re: Visio shape data / user cell in shape text with multiple colors other formatting
Post by: Visisthebest on January 21, 2024, 08:45:57 PM
Thank you Wapperdude!
Title: Re: Visio shape data / user cell in shape text with multiple colors other formatting
Post by: Visisthebest on January 23, 2024, 11:52:22 AM
Again all the valuable information shared here is proof what a great forum this is! :D

I have a prediction for 2024, as the year progresses custom development for Visio web editor is coming as well. The first step is custom shapes and templates in the editor being (almost) fully supported as in the desktop edition, after which custom development for Visio web editor will become possible as well. Visio plan 2 will be required for this, plan 1 will not support it.
Title: Re: Visio shape data / user cell in shape text with multiple colors other formatting
Post by: Surrogate on January 23, 2024, 03:17:43 PM
Quote from: Visisthebest on January 23, 2024, 11:52:22 AMI have a prediction for 2024
WOW!
I read article by David J Parker a long time ago (from 2020), I think back then they were promising it soon...
Quote from: David J Parker in article Customising Visio Shapes for the Web App (https://bvisual.net/customising-visio-shapes-for-the-web-app/)What next?
So you now have a way to create better graphics, add right mouse menus, data and hyperlinks on shapes for general use by Visio Plan 1 users. Visio desktop app users can create a corporate template with custom shapes to improve consistency, presentation and branded appearance for all users of Visio documents.
Title: Re: Visio shape data / user cell in shape text with multiple colors other formatting
Post by: Visisthebest on January 23, 2024, 04:54:34 PM
They underestimated how much work it would be to run the Visio model in a web browser.
Title: Re: Visio shape data / user cell in shape text with multiple colors other formatting
Post by: Surrogate on January 24, 2024, 08:01:42 AM
Quote from: Visisthebest on January 23, 2024, 04:54:34 PMrun the Visio model in a web browser
:)
The purpose of creating a web-based application is to increase the number of potential users. Most of the users (desktop and web) create the simplest schemes (elementary clip-art). ShapeSheet in desktop application is used by about 1% of the total number of users!
Therefore, in my opinion, it makes no sense to transfer all the power of Visio to the web.
Title: Re: Visio shape data / user cell in shape text with multiple colors other formatting
Post by: Visisthebest on January 24, 2024, 10:30:11 AM
But they're doing it anyway Surrogate, and I am happy they're going this way!

I think compatibility with existing diagrams is a huge factor in their consideration to go this way.
Title: Re: Visio shape data / user cell in shape text with multiple colors other formatting
Post by: Surrogate on January 24, 2024, 11:23:03 AM
Good thing they made you happy! Or they will do it a little later by adding this functionality )