Visio Guy

Visio Discussions => Programming & Code => Topic started by: Speedkiller1975 on October 28, 2016, 05:44:01 AM

Title: Change Color of line from with info in random shape.
Post by: Speedkiller1975 on October 28, 2016, 05:44:01 AM
Hallo All.

I'm working on Logic symbols see piture as attachment.

I can change from the shape the input from 1 to 0.

i like to have the line connected to it to change color. i can do this with  a formule IF(Multi Logic.57!Prop.Input_1=1,2,0)

This is working correct.

my problem is
"Multi Logic" is a variable this can be "NOT", "Multi Logic", ect
".57" is a variable number this is given by Visio and can be any number i think
"Prop.Input_1" is a variable this can be "Prop.Input_1", "Prop.Input_2", ect

In the line I have made shape data

Prop.Input = can be Prop.Input_1 or Prop.Input_2 ect. (1 (Type list fix))
Prop.Type_symbol = can be Multi Logic or NOT ect. (1 (Type list fix))
Prop.Number_symbol = " a number the user gives" (2 (Type Number))

if i than use
If(Prop.Input&Prop.Number_symbol&"!"&Prop.Input=1,2,0)

I get the value 0 always.

if I change the 1 to Multi Logic.57!Prop.Input_1 i get a 2.

is there a way to use the variable value in a formule.

i wish it can be done in the shapedata sheet.


If it is in VBA it is also good.
Only I'm not know how to get the data from "Prop.Input, Prop.Type_symbol,Prop.Number_symbol" to VBA and then put it back in the cell Line Format -> LineColor.

i know a bit about Excel VBA and if i do this it works in excel
If i use EXcel vba than this works.

Cell1 = "C4"
Cell2 = "C5"
Formule = "="
Formule = Formule + Cell1
Formule = Formule + "+"
Formule = Formule + Cell2

Range("C6").Formula = Formule

a picture of how it looks
Title: Re: Change Color of line from with info in random shape.
Post by: wapperdude on October 28, 2016, 04:08:16 PM
Hi Speedkiller1975,

So this topic is just a spin of a previous topic...not really new.

As previously by Vojo, cannot do this in shapesheet...need VBA to find the shape.

As indicated by Metuemre, he probably has solution that meets your needs which he'll provide after vacation.  Patience.

The basic VBA steps would go something like this:
  1) select connector
  2) find shape connected to, and capture shape name
  3) get cell info from shape using results method
  4) based upon cell info, change connector line color using formula method.

Wapperdude

Title: Re: Change Color of line from with info in random shape.
Post by: JuneTheSecond on October 29, 2016, 06:51:32 AM
I've received a mail from Yacine to make me aware of  this topics.
I'd made some shapes and connector before for Logical or decimal calculations,
but now I've forgot the details, because I am too old.
http://june2.carrots.jp/english/colorledthemecolor.htm
It is my joy, if any of them is helpful, though I am not sure they are.
Title: Re: Change Color of line from with info in random shape.
Post by: metuemre on November 01, 2016, 07:44:29 AM
As promised, please find attached a sample of Logic Drawing Template file with Function Blocks stencil.
Title: Re: Change Color of line from with info in random shape.
Post by: metuemre on November 01, 2016, 10:28:54 AM
Another way to identify glued shapes and connection points is to use Shape.GluedShapes method and Shape.Connects property. Below is a related topic;

http://visguy.com/vgforum/index.php?topic=3443.0 (http://visguy.com/vgforum/index.php?topic=3443.0)
Title: Re: Change Color of line from with info in random shape.
Post by: Speedkiller1975 on November 01, 2016, 11:54:11 AM
Thanks all
Title: Re: Change Color of line from with info in random shape.
Post by: metuemre on November 02, 2016, 07:23:48 AM
Sample code with Shape.GluedShapes method. Main idea is to synchronize Connection names and Shape Data names,e.g., if a connector is glued to Connections.OUT then it will read the value from Prop.OUT

Private Sub DIConnectionFind(shp As Visio.Shape)

Dim shpIDs() As Long
Dim FromShp As Visio.Shape
Dim ToShp As Visio.Shape
On Error Resume Next
   
shpIDs() = shp.GluedShapes(visGluedShapesIncoming2D, "")
Set FromShp = ActivePage.Shapes.ItemFromID(shpIDs(0))
shpIDs() = shp.GluedShapes(visGluedShapesOutgoing2D, "")
Set ToShp = ActivePage.Shapes.ItemFromID(shpIDs(0))

shp.Cells("User.FromShape").formula = Chr(34) & FromShp.name & Chr(34)
shp.Cells("User.ToShape").formula = Chr(34) & ToShp.name & Chr(34)

shp.Cells("User.FromInput.Prompt").FormulaU = "=SETF(GetRef(Prop.Value),User.FromShape&" & Chr(34) & "!" & "Prop." & shp.Connects(1).ToCell.RowName & Chr(34) & ")"
shp.Cells("User.ToInput.Prompt").FormulaU = "SETF(" & Chr(34) & ToShp.name & "!" & "Prop." & shp.Connects(2).ToCell.RowName & Chr(34) & ",Prop.Value)"

End sub