Selecting all Visio connectors of a certain color

Started by jaushwa, April 24, 2019, 08:05:27 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jaushwa

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

Yacine

#1
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.
Yacine