Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
UpdateLinks error?
hello -
I have a very simple (or so I thought) section of code used to update all external links in a workbook. It seems to update all of the information but before it finishes, I get the following error message: Run-time error '1004': Method 'UpdateLink' of object '_Workbook' failed Here's my code: Private Sub UpdateLinks_Click() Application.DisplayAlerts = False ActiveWorkbook.UpdateLink Name:=ActiveWorkbook.LinkSources Application.DisplayAlerts = True End Sub Any ideas what would cause the error? And, more importantly, how to fix it? TIA, Ray |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
UpdateLinks error?
My guess would be that you have a bad link.
go into Edit=Links, select each link and click the button to update the link. See if one fails. -- Regards, Tom Ogilvy "Ray" wrote: hello - I have a very simple (or so I thought) section of code used to update all external links in a workbook. It seems to update all of the information but before it finishes, I get the following error message: Run-time error '1004': Method 'UpdateLink' of object '_Workbook' failed Here's my code: Private Sub UpdateLinks_Click() Application.DisplayAlerts = False ActiveWorkbook.UpdateLink Name:=ActiveWorkbook.LinkSources Application.DisplayAlerts = True End Sub Any ideas what would cause the error? And, more importantly, how to fix it? TIA, Ray |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
UpdateLinks error?
Did your macro update the links and then cause an error message? I
couldn't even run the script without getting an error. I've posted a sample script that I use to make all of the external links point to the active workbook. I hope it helps. Sub LinkToSelf() Dim Awb As Workbook Dim aLinks Application.ScreenUpdating = False Set Awb = ActiveWorkbook 'Get an array of the external links aLinks = Awb.LinkSources(xlExcelLinks) 'this will return empty if there are not external links 'As long as the array is not empty, loop through the array and change the reference If Not IsEmpty(aLinks) Then For I = LBound(aLinks) To UBound(aLinks) 'error catching in case the external link cannot be changed (if the link references a worksheet 'that exists in the linked workbook, but does not exist in the active workbook, it will cause an 'error and the link will not be changed On Error Resume Next 'Point the link back to the active workbook Awb.ChangeLink Name:=aLinks(I), NewName:=Awb.FullName, Type:=xlLinkTypeExcelLinks On Error GoTo 0 Next I End If Application.ScreenUpdating = True Erase aLinks aLinks = Awb.LinkSources(xlExcelLinks) If Not IsEmpty(aLinks) Then MsgBox "There are still external links in this workbook" End Sub On Mar 13, 6:38 am, "Ray" wrote: hello - I have a very simple (or so I thought) section of code used to update all external links in a workbook. It seems to update all of the information but before it finishes, I get the following error message: Run-time error '1004': Method 'UpdateLink' of object '_Workbook' failed Here's my code: Private Sub UpdateLinks_Click() Application.DisplayAlerts = False ActiveWorkbook.UpdateLink Name:=ActiveWorkbook.LinkSources Application.DisplayAlerts = True End Sub Any ideas what would cause the error? And, more importantly, how to fix it? TIA, Ray |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Disabling updatelinks | Excel Discussion (Misc queries) | |||
Deactivate then Reactivate UpdateLinks | Excel Programming | |||
UpdateLinks | Excel Programming | |||
Help with updatelinks:=3 etc PLEASE | Excel Programming | |||
Updatelinks | Excel Programming |