View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.links
Bill Manville Bill Manville is offline
external usenet poster
 
Posts: 473
Default Problems saving a worksheet with links

You could adapt the code posted in the other thread to ChangeLink
rather than UpdateLink

So, instead of
Sub UpdateActiveWorkbookLinks()

make it
Sub ChangeMasterWorkbookLink()
Dim vLinkSources
Dim iLinkSource As Integer
Dim AnySheet As Worksheet
For Each AnySheet In ActiveWorkbook.Worksheets
ActiveWorkbook.Worksheets(AnySheet.Name).Unprotect
Password:="mypassword"
Next
vLinkSources = ActiveWorkbook.LinkSources(xlExcelLinks)
If Not IsEmpty(vLinkSources) Then
For iLinkSource = LBound(vLinkSources) To UBound(vLinkSources)
If Instr(LCase(vLinkSources(iLinkSource), "master.xls")0 Then
ActiveWorkbook.ChangeLink vLinkSources(iLinkSource), _
"\\Server\MyDir\mySubDir\master.xls" , xlExcelLinks
End If
Next
End If
For Each AnySheet In ActiveWorkbook.Worksheets
ActiveWorkbook.Worksheets(AnySheet.Name).Protect
Password:="mypassword"
Next
End Sub

and call it from the code that loops through all xls files in a
directory.
Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - respond to newsgroup