PDA

View Full Version : Just started VBA tonight, in need of help.



Furyofaserap
03-31-2009, 12:32 AM
Hey guys,

I just started playing with visio's VBA tonight and its a wonderful thing, I've discovered. I do have a bit of a dilema, however.

I have a bunch of shapes that are connected in a flowchart fashion. Each shape has a property called "TheProperty" for the sake of this example. "TheProperty" is a boolean that I can change. What I've got is if "TheProperty" is true, the shape will turn green, if its "false" the shape will turn red.

What I'd like to do is to add another 'state' as it were. I would like to make it so that when I run the macro, the shape will change to blue if all the shapes that are connected to it (but not connected from it) have "TheProperty" as true for all of them.

Again, the real dilema, I'm sensing, is that I have to make a distinction between connections coming in vs connections going out and I don't know how to do that.

Here is my current code.


Sub Test()
Dim pag As Page
Dim shp As Shape

Set pag = Application.ActivePage
For Each shp In pag.Shapes
If shp.CellExists("Prop.TheProperty", True) = True Then
If (shp.Cells("Prop.TheProperty") = False) Then
shp.Cells("FillForegnd") = 2
shp.Cells("Char.Color") = 1
Else
shp.Cells("FillForegnd") = 3
shp.Cells("Char.Color") = 0
End If
' Here's where I need to have the thing mentioned above
If (shp.FromConnects.Count > 0) Then
shp.Cells("FillForegnd") = 4
shp.Cells("Char.Color") = 0
End If

End If
Next shp
Set shpObj = Nothing
Set shpObjs = Nothing

End Sub



I apologize if I am not clear. It's rather early in the morning. I would appreciate any direction someone could give me on this. If anyone needs clarification, let me know.

Many Thanks,
~Rob