Visio Guy

Visio Discussions => ShapeSheet & Smart Shapes => Topic started by: qholmes on July 16, 2018, 08:49:26 PM

Title: Setting a Text Shape's text value
Post by: qholmes on July 16, 2018, 08:49:26 PM
I read a bunch of posts but most are talking about the shape text not a text shapes text.. is it different? not sure. I still could not figure out how to set the text on a text shape.

I have multi shape groups/masters and one of them is a text shape that if possible I would like to set the text on depending on actions in the group/master shape. Do I change the text or just hide and unhide different text shapes. I would rather change the text.

Thanks

Q
Title: Re: Setting a Text Shape's text value
Post by: Surrogate on July 16, 2018, 09:32:10 PM
what you mean as "text shapes" ?
Title: Re: Setting a Text Shape's text value
Post by: qholmes on July 16, 2018, 09:33:47 PM
like a text box.

Q
Title: Re: Setting a Text Shape's text value
Post by: Surrogate on July 16, 2018, 09:40:55 PM
Just rectangle without border-line ?
Title: Re: Setting a Text Shape's text value
Post by: qholmes on July 16, 2018, 09:45:52 PM
On the Home Tab and under Tools the Text tool.

Title: Re: Setting a Text Shape's text value
Post by: wapperdude on July 16, 2018, 11:27:03 PM
Technically, there is no text shape per se.  But, shapes contain a text box.  When you select either of the text tools, then click on a drawing page,and start typing, Visio creates a shape without a border.  The textbox tool, allows you to manipulate and move the textbox independently of the shape, but it still belongs to the shape.

It you want a single shape to have multiple text boxes, then you have to create a group, with a sub shape for each textbox.

To show/hide text, you could use multiple, stacked shapes and show hide text as necessary.  Or, you could use a single shape, some shape sheet functionality, and push appropriate text into textbox.

Attached is example of 2nd method.  The text is defined by the shape data values.  The text selection is determined by the Actions section.  The selected text is pushed into the shape via custom Field Insert formula.

Wapperdude
Title: Re: Setting a Text Shape's text value
Post by: qholmes on July 17, 2018, 12:02:21 AM
Perfect!!!!!!!!!!!!!!!!

I missed the Text Fields group. Everything I had read said there was no way to set text..

Awesome!!!!

Thanks

Q
Title: Re: Setting a Text Shape's text value
Post by: qholmes on July 17, 2018, 12:06:30 AM
Ok,

How do I get Text Fields to show up? I don't see it on my text box or a generic shape I tried?

Q
Title: Re: Setting a Text Shape's text value
Post by: qholmes on July 17, 2018, 12:40:31 PM
ok, figured it out. Insert a Field. with User Cell. I had tried to figure this out before. Finally found the proper MS help doc.

That's the part I was missing the whole time.

Thanks

Q
Title: Re: Setting a Text Shape's text value
Post by: wapperdude on July 17, 2018, 02:39:45 PM
Oh, good job!

Sorry my answer was a bit incomplete.
Title: Re: Setting a Text Shape's text value
Post by: qholmes on July 17, 2018, 02:41:18 PM
Are you kidding.. you got me there. Thanks!!!!!!!!!!!!!!

Q
Title: Re: Setting a Text Shape's text value
Post by: Rob.Bradley on July 27, 2018, 01:47:42 PM
Quote from: wapperdude on July 16, 2018, 11:27:03 PM

Attached is example of 2nd method.  The text is defined by the shape data values.  The text selection is determined by the Actions section.  The selected text is pushed into the shape via custom Field Insert formula.

Wapperdude

I'm building a legend template for a team to use. How do I ask shape to show Filename as text in specific box? I suspect it is the 4th box 'ObjectKind' in the text fields menu on Spreadsheet but am non-VBA user so do not know code to use!

The other part of this question is what kind of shape is your example? The boxes I have do not have 'Text Field' Section in Shapesheet tool menu.

Many thanks, Rob
Title: Re: Setting a Text Shape's text value
Post by: qholmes on July 27, 2018, 01:52:31 PM
Any object and use the insert and Field function. It gives you some options. I am sure you can take it from there. This was the clue I could not find myself.

hope it helps.

Q
Title: Re: Setting a Text Shape's text value
Post by: wapperdude on July 27, 2018, 02:15:48 PM
The Text Field section only appears in the shape sheet after using the Insert> Fields > "whatever" funationality.

I suppose it might be inserted via code...never tried that.

Wapperdude
Title: Re: Setting a Text Shape's text value
Post by: Hey Ken on July 27, 2018, 07:43:36 PM
Wapperdude:

   Funny, but I just wrote a routine to add text fields just this morning.  The method for doing it is non-obvious, and this example only scratches the surface.  The code below will either create or update the first field.  Your mileage may vary.

   - Ken




Public Sub CreateTextField(TheShape As Shape, TheText As String)

Dim TheCharacters As Visio.Characters

If TheShape.CellExists("Fields.Value", 0) Then
Else
    Set TheCharacters = TheShape.Characters
    TheCharacters.Begin = 0
    TheCharacters.End = 0
    TheCharacters.AddCustomFieldU "", visFmtNumGenNoUnits
    End If
   
TheShape.Cells("Fields.Value").Formula = TheText
TheShape.Cells("Fields.Format").Formula = "=FIELDPICTURE(37)"

End Sub