View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Sam Wilson Sam Wilson is offline
external usenet poster
 
Posts: 523
Default Updatelink Error

cLink = Split(aLinks(i), "\")(UBound(Split(aLinks(i), "\")))

shouldn't that be:

cLink = Split(aLinks(i), "\",UBound(Split(aLinks(i), "\")))

Sam

"Cresta" wrote:

Hello all, I am having issue with code below throwing a
Run-time error '1004' Method 'UpdateLink' of object '_Workbook' failed
on this line:- ActiveWorkbook.UpdateLink Name:=cLink, Type:=xlExcelLinks

The correct link name is being displayed when I hover over 'cLink'
Can anyone see where I am going wrong?

With Application.Workbooks(MyExcelFile)
.Activate
aLinks = ActiveWorkbook.LinkSources(xlExcelLinks)
If Not IsEmpty(aLinks) Then
For i = 1 To UBound(aLinks)
cLink = Split(aLinks(i), "\")(UBound(Split(aLinks(i), "\")))
If UCase(cLink) = UCase(Linkname) Then
ActiveWorkbook.UpdateLink Name:=cLink, Type:=xlExcelLinks
End If
Next i
End If
End With

Thankyou for you assistance