Visio Guy

Visio Discussions => Programming & Code => Topic started by: jaushwa on April 24, 2019, 08:05:27 PM

Title: Selecting all Visio connectors of a certain color
Post by: jaushwa on April 24, 2019, 08:05:27 PM
Hi, new here

I'm looking for help with a visio drawing I've been working on, must have about 900 connectors and now the key got changed, changing some of the colors of some of the connectors. I'm trying to highlight all connectors and text of a particular color. 

Thus far in VBA I have,

Sub SelectAll()
     If Shape.linecolor = RGB(0, 112, 192) Then
    Shape.linecolor = RGB(49, 133, 155)
   End If
 

End Sub


But I'm getting Run-time error '424': Object Required.

Please help if possible
Title: Re: Selecting all Visio connectors of a certain color
Post by: Yacine on April 24, 2019, 08:29:34 PM
1. don't override SelectAll, it's a VBA function. Use something else like "select_all".
2. What is Shape? define it. ... and use another name. "Shape" is also part of the object library. --> "shp"?
a. either pass it as argument of the function, or
b. define it as
set shp = activewindow.selection(1) ... or similar
3. x.linecolor is a shapesheet syntax. In VBA write instead:
shp.CellsU("lineColor").FormulaU to read and write the formula of the cell.
4. The formula will be written as string: eg "RGB(49, 133, 155)". Same for the reading operation ( ... = "...").

You may want to use the macro recorder to get the right syntax for your projects.


HTH,
Y.