Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ray Ray is offline
external usenet poster
 
Posts: 267
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Disabling updatelinks Dave Excel Discussion (Misc queries) 0 April 27th 06 12:05 PM
Deactivate then Reactivate UpdateLinks TOMB Excel Programming 2 February 24th 06 10:20 PM
UpdateLinks Howard Kaikow Excel Programming 8 September 26th 05 03:27 PM
Help with updatelinks:=3 etc PLEASE Mick[_3_] Excel Programming 3 August 7th 04 03:51 PM
Updatelinks Mick Southam Excel Programming 0 August 3rd 04 04:01 PM


All times are GMT +1. The time now is 02:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"