Updatelink Error

C

Cresta

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
 
S

Sam Wilson

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

shouldn't that be:

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

Sam
 

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

Top