Break all links VBA

davec8723

New Member
Joined
Jul 29, 2011
Messages
45
Hi,

Does anyone know how to break all links using VBA quickly? I am using Excel 2003.

For some reason this code does not work for me, which I have been finding all over the internet.

Code:
Sub BreakLinks()
    Dim vLinks As Variant
    Dim lLink As Long
 
    ' Define variable as an Excel link type.
    vLinks = ActiveWorkbook.LinkSources(Type:=xlLinkTypeExcelLinks)
    If vLinks = vbNullString Then Exit Sub
 
    ' Break all links in the active workbook.
    For lLink = LBound(vLinks) To UBound(vLinks)
        ActiveWorkbook.BreakLink _
                Name:=vLinks(lLink), _
                Type:=xlLinkTypeExcelLinks
    Next lLink
End Sub

Thank You!







</PRE>
 
Last edited:

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Try code below. Does it help?

Code:
Sub BreakLinks()
    Dim aLinksArray As Variant
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    Application.Calculation = xlCalculationManual
    
    
    aLinksArray = ActiveWorkbook.LinkSources(Type:=xlLinkTypeExcelLinks)
    
    Do Until IsEmpty(aLinksArray)
        ActiveWorkbook.BreakLink Name:=aLinksArray(1), Type:=xlLinkTypeExcelLinks
        aLinksArray = ActiveWorkbook.LinkSources(Type:=xlLinkTypeExcelLinks)
    Loop
    
     Application.ScreenUpdating = True
     Application.DisplayAlerts = True
     Application.Calculation = xlCalculationAutomatic
End Sub

Biz
 
Upvote 0
This is the function I have always used. Similar to what you have, but let me know if it works for you.

Code:
Sub BreakLinks()
Dim Links As Variant
Links = ActiveWorkbook.LinkSources(Type:=xlLinkTypeExcelLinks)
For i = 1 To UBound(Links)
ActiveWorkbook.BreakLink _
    Name:=Links(i), _
    Type:=xlLinkTypeExcelLinks
Next i
End Sub

If it is still not working perhaps you can give a little more detail as to what exactly is happening?
 
Upvote 0
What kind of links are you breaking? Does the break link function work manually?
 
Upvote 0
Hi,

Now that you mention it, the links will not break manually either.. Sorry I should have checked that first.. Any idea why they will not break? It does not return an error or anything, the link simply does not disappear from the list.

Thanks,
Dave
 
Upvote 0
I suspect the links are in defined names or charts. Have you tried Bill Manville's FindLink addin?
 
Upvote 0
This is the function I have always used. Similar to what you have, but let me know if it works for you.

Code:
Sub BreakLinks()
Dim Links As Variant
Links = ActiveWorkbook.LinkSources(Type:=xlLinkTypeExcelLinks)
For i = 1 To UBound(Links)
ActiveWorkbook.BreakLink _
    Name:=Links(i), _
    Type:=xlLinkTypeExcelLinks
Next i
End Sub

If it is still not working perhaps you can give a little more detail as to what exactly is happening?

Hi,

Could you help me for multi-workbooks?

how can i break all links for multiple workbooks?

thanks

Onur
 
Upvote 0
I tried the code above but it would not remove a stubborn data link. However, I discovered that if I went to Formulas/Name Manager and removed all names where the reference was no longer valid then I could break the link manually.
 
Upvote 0

Forum statistics

Threads
1,216,540
Messages
6,131,255
Members
449,638
Latest member
ygdalvi

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