Run-time error 1004: Method 'UpdateLink'

C

ChrisP

When running this code in excel I am getting the following error:

Run-time error '1004':
Method 'UpdateLink' of object '_Workbook' failed

What's wrong? Here is the code I'm using:

Sub UpdateSelectedLinks()
Dim aLinks
Dim cLink As String
Dim i As Integer
Application.ScreenUpdating = False
aLinks = ActiveWorkbook.LinkSources(xlExcelLinks)
If Not IsEmpty(aLinks) Then
For i = 1 To UBound(aLinks)
cLink = Split(aLinks(i), "\")(UBound(Split(aLinks(i), "\")))
If cLink <> "MasterList.xls" Then
ActiveWorkbook.UpdateLink Name:=aLinks(i), Type:=xlExcelLinks
End If
Next i
End If
Application.ScreenUpdating = True
End Sub

When I choose to debug the row that's hightlighted is "
ActiveWorkbook.UpdateLink Name:=aLinks(i), Type:=xlExcelLinks"

HELP!!!

Thanks!
 
M

macropod

Hi Chris,

I think I've already answered this in your other thread - 'Update links in Excel using VBA'.
 
P

Pipeliner

How can I get to see your answer in the other thread? Thanks.

macropod said:
Hi Chris,

I think I've already answered this in your other thread - 'Update links in Excel using VBA'.

--
Cheers
macropod
[MVP - Microsoft Word]


ChrisP said:
When running this code in excel I am getting the following error:

Run-time error '1004':
Method 'UpdateLink' of object '_Workbook' failed

What's wrong? Here is the code I'm using:

Sub UpdateSelectedLinks()
Dim aLinks
Dim cLink As String
Dim i As Integer
Application.ScreenUpdating = False
aLinks = ActiveWorkbook.LinkSources(xlExcelLinks)
If Not IsEmpty(aLinks) Then
For i = 1 To UBound(aLinks)
cLink = Split(aLinks(i), "\")(UBound(Split(aLinks(i), "\")))
If cLink <> "MasterList.xls" Then
ActiveWorkbook.UpdateLink Name:=aLinks(i), Type:=xlExcelLinks
End If
Next i
End If
Application.ScreenUpdating = True
End Sub

When I choose to debug the row that's hightlighted is "
ActiveWorkbook.UpdateLink Name:=aLinks(i), Type:=xlExcelLinks"

HELP!!!

Thanks!
 

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