Text field conditional to something

Started by oxmo, July 05, 2017, 08:12:05 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

oxmo

Hi,

I would like to be able to change a textbox conditional on "something".
I have created a textbox (CTRL+2), I gave it a fixed list through shape data, inserted a field so now I can make my text change from "yes" to "no" with a drop down list and that's fine, except I would like to change a paragraph of text with a specific formatting, not just a word.
Any help please?

Thank you!

Yacine

This won't work with shapesheet fields. They don't support natively formating.
What you could do instead, is making a group of shapes containing the formatted paragaph and show/hide them at group level.
Look at Visio Guy's article on the hidden world of shapes to get yourself started.

If you lock the text editing of the group, then the top upmost shape will be edited when hitting F2, so you may want to play with the Z-Order as well. Note from V2010 on there are formulas at shapesheet level to edit the Z-Order.
Otherwise you could play with docmd at sub-shape level and an action row at group level to edit the texts of the sub-shapes.
Yacine

wapperdude

There is limited formatting that can be done within the shapesheet, generally of a "global" nature...font, char size, etc. So, an entire shape text can be easily varied.

However, portions of text, i.e., text within a string, generally require the use of macros. 

Wapperdude

Visio 2019 Pro

Yacine

Tried to work out a solution ...
did however not find a solution for fast editing by F2.
Yacine

oxmo

Thank you very much guys, but in the meantime I've found 2 videos on youtube.
https://www.youtube.com/watch?v=iV9Jb3jc7DU
https://www.youtube.com/watch?v=Kbp_k1IfApY
So the easiest way would be to put text on various layers and to activate the desired layer by doing "something".
In the second video he explains how to activate layers based on check boxes, but I would prefer to activate layers with a drop-down list, since I only want 1 layer to be activated from the list of option.
I just need to try to figure out how to merge both his tutorial.
My next step would be to activate the layer "banana" on multiple pages. Right now the layers seems to be page specific. If I close a layer on page 1 it doesn't close on page 2.
My last step would be to link 2 text boxes. When I type "Purple" in text box 1, I want the text box 2 to replicate the text from text box 1.
Thanks!

wapperdude

#5
Layers are page specific, including their order in the list for each page.

Assuming that all of the pages have the same order, then you could merely loop thru the pages in the document.  Something like the following.  This has no error detection, so, if the pages don't have proper number of layers, the code could fail.


Sub Macro1(A As Integer, B As Integer, C As Integer)
' The terms A, B, and C merely pass values of 0 or 1 to the layer visibility cells.
'"1" = visible
'"0" = hidden

    Dim vsoLayer1 As Visio.Layer
    Dim vsoPg As Page
       
    For Each vsoPg In ActiveDocument.Pages
        If vsoPg.Background = False Then
            Set vsoLayer1 = vsoPg.Layers.Item(1)
            vsoLayer1.CellsC(visLayerVisible).FormulaU = A
            Set vsoLayer1 = vsoPg.Layers.Item(2)
            vsoLayer1.CellsC(visLayerVisible).FormulaU = B
            Set vsoLayer1 = vsoPg.Layers.Item(3)
            vsoLayer1.CellsC(visLayerVisible).FormulaU = C
        End If
    Next

End Sub


Wapperdude
Visio 2019 Pro

Yacine

#6
GIF Animation of my previously posted shape
Yacine

wapperdude

The advantage of Yacine's approach is no macro needed, thus avoiding any security concerns.

Both approaches are adaptable.  Either you take over now, or you provide more detailed info so we can determine exactly what you're doing and need.

Wapperdude
Visio 2019 Pro

oxmo

I do prefer a macroless solution.
I've downloaded the Visio file, I was able to switch between the 3 formatted text and modify them, but I have no clue how you did that.
I right-clicked on the shape>data>shape data. There's the Fixed list, Format: 1;2;3. So I changed 1;2;3 for city names, but the text disappears from the shape.
At work, we uses different Visio files depending on where the job will be and which language will be used for the job. i.e.: New York English, Paris French, Paris English. So instead of having different files, I would like to have one template file that has all the pre filled info in the appropriate language and the city info.
Thank you guys!

Yacine

#9
So I played a little bit and added some features.
- The list is now free to edit. Only the position in the list matters. The link to the sub-shape is a the field prop.nr of the sub-shape.
- The number of sub-shapes is in so far easy to increase, as prop.nr is incremented by one when the sub-shape is duplicated. Make sure to duplicate always the field with the highest number.
- The parent shape got a new field prop.edit, which allows to unhide the sub-shapes and place them next to each other in order to edit them easily.
- The position of the text relatively to the parent shape is now linked to a control point. This may be useful, if the text hides too much of the parent shape.


Yacine

Yacine

Yacine

oxmo

That's amazing!
Now I just need to decipher your instructions since I'm a total Visio n00b:
I might be back with more questions in a few weeks since I work on this whenever I have spare time and spare time is rare.

Danke!

oxmo

Hi,

I'm back with a mock-up document of what I would like to do in Visio, so it's easier to explain what I need.
My knowledge of Visio and programming in general is quite limited.
What I would like to know is what to look for to be able to do what I want to do:
(because I don't even know what to Google)

  • Text that changes on the print area according to my drop-down selection outside the print area
  • Text that changes on the print area according to what I've entered in a text box outside the print area (this way I can switch between text box by pressing the TAB key)
  • Some of the data entered and selected on the first page should be linked to the following pages in a title block
So if you could please throw some technical terms that I could Google and try to learn on my own, that would be greatly appreciated.
I prefer not to use VBA, if that's even an option.

Thank you!

Yacine

Why is it, you use Visio for the task?
Yacine

oxmo

We make technical schematics manuals. AutoCAD could do the trick, but Visio is way cheaper. The connector tool is quite useful too. We have schematics and we create a part list in Excel that we copy-paste special in Visio so we can modify the list in Excel and it updates automatically in Visio. Then when it's done we convert everything in PDF. The title page is currently made in Word and I'm trying to find a way to: 1. Stop typing info to save time by selecting from drop down list and it will prevent typos 2. If we need to change some info, it will automatically change it elsewhere, again to save time and not to forget to change it elsewhere.