Breaking links in a macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a command to break all links at once? I have 70 spreadsheets and
need to open, save as, and break a dozen links and the links are different in
each one. I would rather not have to edit the names of all the links if there
is an easier way. Thanks!
 
Sub UseBreakLink()

Dim astrLinks As Variant

' Define variable as an Excel link type.
astrLinks = ActiveWorkbook.LinkSources(Type:=xlLinkTypeExcelLinks)

' Break the first link in the active workbook.
for i = lbound(astrlinks) to ubound(astrlinks)
ActiveWorkbook.BreakLink _
Name:=astrLinks(i), _
Type:=xlLinkTypeExcelLinks
Next i

End Sub
 
Just some added info:
Breaklink was introduced in xl2002 or xl2003 - I don't recall which.
 
Hi,

the easiest way to break links to another excel file:

Sub BreakLinks()
Dim varLinks As Variant
varLinks = ActiveWorkbook.LinkSources(Type:=xlLinkTypeExcelLinks)
On Error Resume Next
Do
ActiveWorkbook.BreakLink _
Name:=varLinks(1), _
Type:=xlLinkTypeExcelLinks
Loop While Err = 0
End Sub

Regards,
Ivan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top