VBA Code to Update Links

stephen.smith

Board Regular
Joined
Jul 7, 2010
Messages
119
Hey Guys I am trying to update links from other workbooks by using VBA rather than updating through the standard Edit Links-> Update all values. Does anyone know how to do this with VBA. I know this is probably very basic but I cant seem to get it to work.
Thanks Again for anyone that has a look and helps me out.
Stephen
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Sorry I should also mention that some of the workbooks that I am trying to update with this VBA are password protected. Can I put the password in the code so that it doesnt prompt me to enter the password.
Thanks
Stephen
 
Upvote 0
I don't see any option to provide a password in the updatelink method - it doesn't appear to be possible.
 
Upvote 0
Code:
Sub Foo()
    Workbooks.Open Filename:="C:File1.xls"
    Workbooks.Open Filename:="C:\File2.xls", Password:="1234"
    Workbooks.Close "File1.xls"
    Workbooks.Close "File2.xls"
End Sub

Personally I'd just remove the passwords. Use a secure folder which is better protection anyway.
 
Upvote 0
Hi thanks for that I have adjusted it slightly to add in a save for the workbooks that open however I am getting a message when the workbooks open saying "The workbook contains one or more links that cannot be updated. I then have to choose "Continue" or "edit links". How can I bypass this or what is going wrong? I cant take the passwords off the individual files as they are all sensitive documents for different employees and are accessed individually. Thanks for the help so far.
Stephen
 
Upvote 0
I'm not sure this is what you want to hear but what I would do is fix the bad links ...
 
Upvote 0
Suppress the application alerts by:
Code:
Sub Alerts()
Application.DisplayAlerts = False
'Place your code here!
Application.DisplayAlerts = True
End Sub
Edit: And what Xenou has said as if the whole thing is messed up then chances are that you won't even notice!
 
Upvote 0

Forum statistics

Threads
1,216,119
Messages
6,128,947
Members
449,480
Latest member
yesitisasport

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