ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Breaking links in a macro (https://www.excelbanter.com/excel-programming/362161-breaking-links-macro.html)

Tim G.

Breaking links in a macro
 
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!

Tom Ogilvy

Breaking links in a macro
 
Sub UseBreakLink()

Dim astrLinks As Variant

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

' 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


--
Regards,
Tom Ogilvy


"Tim G." wrote:

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!


Tom Ogilvy

Breaking links in a macro
 
Just some added info:
Breaklink was introduced in xl2002 or xl2003 - I don't recall which.

--
Regards,
Tom Ogilvy


"Tim G." wrote:

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!


Ivan Raiminius

Breaking links in a macro
 
Hi,

the easiest way to break links to another excel file:

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

Regards,
Ivan



All times are GMT +1. The time now is 10:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com