Disable all External Links

JMH022

Active Member
Joined
Mar 7, 2002
Messages
320
Hello all!

I have a workbook with multiple connections. I would like to know if there is a way through VBA to disable all connections simultaneously instead of having to list out

ActiveWorkbook.Connections("Connection").Delete
ActiveWorkbook.Connections("Connection1").Delete
ActiveWorkbook.Connections("Connection2").Delete
ActiveWorkbook.Connections("Connection3").Delete
ActiveWorkbook.Connections("Connection4").Delete
ActiveWorkbook.Connections("Connection5").Delete
ActiveWorkbook.Connections("Connection6").Delete
ActiveWorkbook.Connections("Connection7").Delete
ActiveWorkbook.Connections("Connection8").Delete
ActiveWorkbook.Connections("Mydb").Delete
ActiveWorkbook.Connections("MyOtherdb").Delete


and so on...

I suppose I could do a Loop and increment the Connection number each time, but I would rather use a command like ActiveWorkbook.AllConnections.Delete, if there is such a thing.

Appreciatively,
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Try this:
(Not my code)

Sub BreakLinks()
Dim LinksList As Variant
Dim i As Integer
LinksList = ActiveWorkbook.LinkSources(Type:=xlLinkTypeExcelLinks)
If IsArray(LinksList) Then
For i = LBound(LinksList) To UBound(LinksList)
ActiveWorkbook.BreakLink Name:=LinksList(i), Type:=xlLinkTypeExcelLinks
Next i
End If
End Sub
 
Upvote 0
Colin: Thank you for your reply. This code didn't work for me. The connections are all still present.
 
Upvote 0

Forum statistics

Threads
1,224,616
Messages
6,179,911
Members
452,949
Latest member
beartooth91

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
Back
Top