Deactivate connectors from shapes

Doflamingo

Board Regular
Joined
Apr 16, 2019
Messages
238
Hi all :)

Does anyone know a VBA code that would allow me to deactivate connectors from shapes.

Here see an example

https://www.dropbox.com/s/e7m5qdre9m1riwp/Untitled.png?dl=0

Because what I would like is to turn the shapes at 180 degrees without moving the connectors. That's why I'm looking for how to deactivate connectors from the shapes, rotate the shapes and then reconnect the connectors to the shapes

Thanks for your help :)

Any ideas is welcomed
 

Some videos you may like

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,406
I haven't looked at your file, but you can use the BeginDisconnect and EndDisconnect methods...

Code:
    conn.ConnectorFormat.BeginDisconnect
    conn.ConnectorFormat.EndDisconnect

...where conn is a variable that represents a connector shape.

Hope this helps!
 

Doflamingo

Board Regular
Joined
Apr 16, 2019
Messages
238
Hi Domenic, thanks for your prompt reply

Here is the code to create shapes linked with connectors

Code:
Sub créeShape(parent, niv, Attribut, coul) ' procédure récursive
  hauteurshape = 48
  largeurshape = 92
  colonne = colonne + 1
  'Forme des éléments
  forga.Shapes.AddShape(msoShapeRectangle, 10, 10, largeurshape, hauteurshape).Name = parent
  forga.Shapes(parent).Line.ForeColor.SchemeColor = 0
  txt = parent & vbLf & Attribut
  With forga.Shapes(parent)
    .TextFrame.Characters.Text = txt
    'taille de la police
    .TextFrame.Characters(Start:=1, Length:=1000).Font.Size = 10
    .TextFrame.Characters(Start:=1, Length:=1000).Font.ColorIndex = 0
    .TextFrame.Characters(Start:=1, Length:=Len(parent)).Font.Bold = True
    'couleur de la police
    .TextFrame.Characters(Start:=1, Length:=Len(parent)).Font.ColorIndex = 1
    'couleur intérieur des formes
    .Fill.ForeColor.RGB = coul
    '.Fill.ForeColor.RGB = RGB(255, 0, 0)
  End With
  forga.Shapes(parent).Left = débutOrg.Left + inth * colonne
  forga.Shapes(parent).Top = débutOrg.Top + intv * (niv - 1)
  For i = 1 To n
    If Tbl(i, 1) = parent And niv > 1 Then
      shapePère = Tbl(i, 2)
      'forga.Shapes.AddConnector(msoConnectorElbow, 100, 100, 100, 100).Name = parent & "c"
      forga.Shapes.AddConnector(msoConnectorElbow, 0, 0, 100, 100).Name = parent & "c"
      forga.Shapes(parent & "c").Line.ForeColor.SchemeColor = 0
      forga.Shapes(parent & "c").ConnectorFormat.BeginConnect forga.Shapes(shapePère), 3
      forga.Shapes(parent & "c").ConnectorFormat.EndConnect forga.Shapes(parent), 1
   End If
   If Tbl(i, 2) = parent Then créeShape Tbl(i, 1), niv + 1, Tbl(i, 3), f.Cells(i + 1, 1).Interior.Color
  Next i
End Sub

And here is the macro to run the previous code


Code:
Dim colonne, débutOrg, f, forga, inth, intv, Tbl(), n
Sub DessineOrga()
   Set forga = Sheets("Structure Chart")
   Set f = Sheets("Data")
   Tbl = f.Range("A2:C" & f.[A65000].End(xlUp).Row).Value
   n = UBound(Tbl)
   For Each S In forga.Shapes
    If S.Type = 17 Or S.Type = 1 Then S.Delete
   Next
   inth = 70
   intv = 60
   colonne = 0
   Set débutOrg = forga.Range("o4")
   'décide de la couleur de l'entité mother dans feuille data
   créeShape Tbl(1, 1), 1, Tbl(1, 3), f.Cells(2, 1).Interior.Color
End Sub

As you can see, that code can create as many connectors than there are shapes and the connectors used are ''msoconnectorelbow"

I'm going to see if I can adapt the line you gave me to the variables of that code

thanks again @Domenic
 

Watch MrExcel Video

Forum statistics

Threads
1,122,732
Messages
5,597,798
Members
414,176
Latest member
LK88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top