update links via vba

daveyc18

Well-known Member
Joined
Feb 11, 2013
Messages
782
Office Version
  1. 365
  2. 2010
hi is there a way? i recorded but it's not working


ActiveWorkbook.UpdateLink Name:= _
"c:\Rpt\CORP\\Rep_Link.xls", Type:= _
xlExcelLinks
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Try:
Code:
ActiveWorkbook.UpdateLink Name:= "c:\Rpt\CORP\Rep_Link.xls", _
                                     Type:= xlExcelLinks

You had a double \ in your path
 
Upvote 0
Try:
Code:
ActiveWorkbook.UpdateLink Name:= "c:\Rpt\CORP\Rep_Link.xls", _
                                     Type:= xlExcelLinks

You had a double \ in your path

corrected it.....says "method updatelink" of ojbect workbook failed
 
Upvote 0
Read this post on Ozgrid, particular the answer from Ger Plante. It may answer your problem
 
Upvote 0
Have you tried
Code:
ActiveWorkbook.UpdateLink Name:=ActiveWorkbook.LinkSources, Type:=xlExcelLinks

it will update all linked workbooks.

If that works OK, then there is something wrong with the path you supply.

If it works, but you only want to update using one of the workbooks and not the others, then you can loop through each and do only the one:


Code:
Dim link as Workbook, LinkSources
linkSources = ThisWorkbook.linkSources(xlExcelLinks)
If IsArray(linkSources) Then
    For Each link In linkSources
        If Instr(Link.Name,"Rep_Link") Then  
            ThisWorkbook.UpdateLink Link.Name, XlLinkType.xlLinkTypeExcelLinks
            Exit For
        End If
    Next
End If
 
Last edited:
Upvote 0
Have you tried
Code:
ActiveWorkbook.UpdateLink Name:=ActiveWorkbook.LinkSources, Type:=xlExcelLinks

it will update all linked workbooks.

If that works OK, then there is something wrong with the path you supply.

If it works, but you only want to update using one of the workbooks and not the others, then you can loop through each and do only the one:


Code:
Dim link as Workbook, LinkSources
linkSources = ThisWorkbook.linkSources(xlExcelLinks)
If IsArray(linkSources) Then
    For Each link In linkSources
        If Instr(Link.Name,"Rep_Link") Then  
            ThisWorkbook.UpdateLink Link.Name, XlLinkType.xlLinkTypeExcelLinks
            Exit For
        End If
    Next
End If

first macro worked fine..thanks!
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,198
Members
453,022
Latest member
RobertV1609

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top