Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BreakLinks method doesn't work. 1

Status
Not open for further replies.

Goppi

Programmer
Jun 21, 2003
40
GB
I've got 2 excel workbooks - lets call them "Data" and "Control" - and try to break all external links in the Data file from within the Control file. In the Control file I've created following a function:

Private Function BreakLinks()
aLinks = Workbooks("Data.xls").LinkSources(xlLinkTypeExcelLinks)
If Not IsEmpty(aLinks) Then
For i = 1 To UBound(aLinks)
Workbooks("Data.xls").BreakLink(aLinks(i), xlLinkTypeExcelLinks)
Next i
End If
End Function

This code produces the error message: "Compile error, Expected: =". When I changed that line to
Workbooks("Data.xls").BreakLink Name:=aLinks(i), Type:=xlLinkTypeExcelLinks
the compiler didn't report an error, however when I try to execute the code it comes up with the error: run-time error'1004', Method 'BreakLink' of object '_Workbook' failed"

Any idea what in either case the problem could be?

Thanks in advance...
 
And what about this ?
For i = UBound(aLinks) To 1 Step -1
Workbooks("Data.xls").BreakLink aLinks(i), xlLinkTypeExcelLinks
Next i

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Interesting - it works. But I wondering why...
If the items in the array would get deleted than I would understand it, but that's not the case...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top