LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default changelink macro failing. Prior link is to a non existent file.

Just wondering if anyone can help me with this. I have a file template that
is linked to another template's new book. The template is paperwork.xlt and
the link is to paperwork1. If I use the edit links in the toolbar the change
link works. My macro works when the link is to a file.xls but fails with an
error message telling me I need to unprotect the sheet. If I write the
command to unprotect the sheet the error msg is removed but the link is still
left unchanged. Below I have left my code. Any idea's would be appreciatted.
Sub Restorelinks()

On Error GoTo ErrorHandler
Dim PATH, link, savefilename As String

Application.ScreenUpdating = False

Const iTitle = "Link To New Workbook" ' title of dialog box
Const FilterList = "Microsoft Excel Workbook (*.xls),*.xls"
PATH = Application.GetSaveAsFilename(savefilename, FilterList, , iTitle,
vbOKCancel)

If PATH = "False" Then
MsgBox "You have chosen to not restore Links. If this is a mistake you
will have to start over.", vbOKOnly, "Restore Link Failure"
Exit Sub
End If

aLinks = ActiveWorkbook.LinkSources(xlExcelLinks)
If Not IsEmpty(aLinks) Then
For i = 1 To UBound(aLinks)
link = aLinks(i)
Next i
End If

ThisWorkbook.ChangeLink link, PATH, xlExcelLinks

Application.ScreenUpdating = True

ErrorHandler:
If Err.Number < 0 Then
MsgBox "error occured"
Exit Sub
End If
End Sub



--
Thanks!
Shane W
 
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
How do I run a macro upon saving a file but prior to actual save? Hawk186 Excel Discussion (Misc queries) 2 June 6th 08 09:38 PM
Link to non-existent files? Ray Excel Discussion (Misc queries) 1 January 17th 07 02:56 PM
changelink with the name and new name as strings is failing whylite Excel Programming 1 February 17th 06 05:08 AM
Link 'failing' ppetts Links and Linking in Excel 1 October 5th 05 06:20 AM
Paste As Link Failing xcelion Excel Programming 3 November 24th 04 03:19 PM


All times are GMT +1. The time now is 01:18 PM.

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

About Us

"It's about Microsoft Excel"