Text Boxes Lines - changing

Started by tclane, May 18, 2017, 08:43:59 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

tclane

Hi

I previously used Visio 2007/2010  and now using 2013

in my case I have diagrams with lines and text boxes( with no line around text box)

I have the requirement that at the beginning the lines and text boxes are all 1 colour e.g blue

but after a period I need to change them all to black ( default colour)

on the older versions I could select all items the diagram, Ctrl A  and change the colour of the line

this would change all the lines in the Diagram but would not change the textboxes if they didn't have a line around them.

On 2013 when I repeat this a line is added around the text box which is not what I require.

the diagram has a lot of lines and small text boxes so don't want to have to uncheck the Text boxes manually from the Selection

can anyone offer some advise to me how do I go about doing this in 2013?

thanks in advance

tclane


Hi Guys

any assistance here please would be greatly appreciated

Yacine

best would be to work with styles and themes, but you can also use a small macro.

Sub select1D()
Dim shp As Shape
For Each shp In ActivePage.Shapes
    If shp.OneD Then
        ActiveWindow.Select shp, visSelect
    End If
Next shp
End Sub
Yacine

tclane

Thanks Yacine


When I use the Styles it changes every textbox Line on the page I don't want to change them at all

but want to change all the other lines on the page ( maybe hundreds of lines)

not sure how to implement the macros

can you give me some instructions

thanks again for the assistance

tclane

Hi Yacine

sorry to annoy you

but do you have a procedure to use this macro

Yacine

Hi tclane,
copy the code I posted into a new module of the drawing (or a stencil), then you can run it to select the connectors.
Guess I don't really understand your question.
Yacine

tclane

Hi Yacine

can you give me the steps to do as you advised?

"copy the code I posted into a new module of the drawing (or a stencil), then you can run it to select the connectors"


I am a novice at visio

thanks again for your assistance in this

Tom


Yacine

Hi Tom,
I feel torn between the will of helping and the impression of being used by someone too lazy to work out be himself the very basics.
Sorry for my rudeness.
Explaining the steps (so in deep) would require me much more work than implementing the whole solution by myself for you.
I'm confused about how to handle your request.
Yacine

wapperdude

#8
@tclane:  taking your question literally,

1) With Visio and your file open and running, press <alt> + f11.  This brings up the VBA window
2) assuming no code exists, in the small left window, double click ThisDocument(xyz).  Xyz = your filename.
3) this makes large window on the right active
4) paste Yacine's code into this window.

To run the code, you can do that from
1): this window:  either the Run entry, or the right pointing triangle.
2): from the drawing window...tools>Macros>This Document>the macro.

This is the flow for V2007, for the ribbon, will be different.  Think it's under Developer tab.

Wapperdude
Visio 2019 Pro

tclane

thanks wapperdude  and Sorry Yacine. I am a beginner with Visio when it gets any further than creating and editing line diagrams

I have the Macros working now. following the steps provided.

but unfortunately it doesn't solve my issue and maybe its unsolvable

I have attached an example which I should have done originally

in the top diagram I have connectors boxes and text( with no Lines around it)

in 2007/2010 version I could select all of diagram and change the colour of the lines and none of the text boxes that had no line before would add a line to it .

But in 2013 when I do the same action. Select all edit the line colour all the text boxes that have no line around them now have a coloured line. as per the second diagram in blue.  I don't want all the text labels on the lines to have a coloured line around them

the Visio documents are created by a planning tool

and there are hundreds of lines and text boxes labels in my documents and it takes so long to have to change all these text labels separately  to the rest of the doc.

thanks for all the assistance so far and apologies for the lack of Knowledge

Tom


wapperdude

I downloaded your example, ran it in V2007 as that's what I have.  The macro runs as expected, selects only 1D shapes.  Note, some of your 1D shapes are part of a group, and the macro as written won't push down into group,  so, some 1D shapes don't get selected.

There was no issue with textbox lines, but, I believe this just supports your original post issue.  Nonetheless, on the surface, it looks as though the macro should work.  Obviously, you must have more going on as that macro does nothing but select 1D shapes.

Not knowing what the complete picture of your code / efforts looks like, try the following one line change to the macro.  It will merely change the color of the 1D shapes to black.  You can change the RGB values to get a different color if preferred.  If all you do is run the modified macro, then, only 1D lines should change color.


Sub select1D()
Dim shp As Shape
For Each shp In ActivePage.Shapes
    If shp.OneD Then
        ActiveWindow.Select shp, visSelect
        shp.CellsU("LineColor").Formula = "RGB(0,0,0)"
    End If
Next shp
DeselectAll
End Sub


Wapperdude
Visio 2019 Pro

tclane

Thanks again wapperdude

appreciate your time helping me

originally I didn't have any marcos in my file.

I only added to try to solve the problem.

but looking at the Code you guys are sending me is it possible to write code as follows

that when all the items in the diagram are selected ( Ctlr A)  that when the Line colour is changed for all items that there is no lines added to the text boxes?

If this is impossible let me know and I will leave you guys in peace and change them all manually :-( 

this is because my drawing starts it is all in Blue but after it has been built /installed it changes to black and there are hundreds of lines and boxes like the example I provided.



thanks again for the help




wapperdude

I can't give exact code because V2013 object model has useful statements not in V2007.  But an outline e of the approach could go something like this...

It would start same as Yacine's code:

For each shape on the active page.  (Note, this is VBA f or <cntl>+A)
  If 1D then                                  'this takes care of all top level 1D shapes
     Do something to shape
  Else if shape = group then.          '  begin pushing into group
      For each sub shape
         Check for 1D
         Check for group......
Next

This could (should be set up as recursive loop) in order to traverse to the lowest nested sub shape.

Unfortunately, I don't have a lot of free time this week.

There have been some examples of recursive loops on the forum.
Here's a reference for groups and subshapes:  https://msdn.microsoft.com/en-us/library/office/ff767900.aspx

Wapperdude



 

Visio 2019 Pro

Yacine

I did also check your drawing and found out that the shapes a properly formated with styles.
There was one that did exactly what you wanted (1D shapes) but without altering the text boxes.
Unfortunately I could not decipher the asian characters, so I can't tell the name.
Fact is, if you modify the style in the drawing explorer, you can elegantly modify the drawing.
-----
Your request regarding the Ctrl-A is not feasable.
-----
You may also use the "Sharem" tool I uploaded to the forum.
The script would be
IF beginX exists THEN
linecolor:=RGB(0,0,0);
ENDIF
You can store the script in the database of the tool and run it for each drawing you open.
Yacine