PDA

View Full Version : Workbook OPEN Event Code - Update Links



xluser2007
06-11-2009, 06:09 AM
Hi All,

Is there a code to place in a Workbook_Open event code, to automatically update all links for that specific workbook, without prompting the user to select update or not update?

Normally, I click NO to update links for any workbooks that I open repeatedly, as is perferable, though for this one particular workbook, I would like to update automatically upon opening without prompting the User for a YES or NO (i.e. Don't update links).

Any help appreciated.

Simon Lloyd
06-11-2009, 06:46 AM
Hi All,

Is there a code to place in a Workbook_Open event code, to automatically update all links for that specific workbook, without prompting the user to select update or not update?

Normally, I click NO to update links for any workbooks that I open repeatedly, as is perferable, though for this one particular workbook, I would like to update automatically upon opening without prompting the User for a YES or NO (i.e. Don't update links).

Any help appreciated.Try this in the thisworkbook module
Private Sub Workbook_Open()
With ThisWorkbook
.UpdateLinks = xlUpdateLinksAlways
End With
End Sub

xluser2007
06-11-2009, 06:49 AM
Hi Simon,

many thanks for your interest.

I tried that, but it still gave the update links dialog box. It appears that it throws this in-built dialog up before actually accessing the Workbook_open code.

Do you get the same issue?

Simon Lloyd
06-11-2009, 07:04 AM
To be honest i didn't try it!, however you can try surronding it with


Private Sub Workbook_Open()
Application.DisplayAlerts=False
With ThisWorkbook
.UpdateLinks = xlUpdateLinksAlways
End With
Application.DisplayAlerts=True
End Sub

xluser2007
06-11-2009, 07:12 AM
Thanks Simon,

That is a good idea, but unfortunately it does not work.

It appears that that updatelinks form is triggerred before the workbook_OPEN event.

Any other such ideas, I'm game!

Bob Phillips
06-18-2009, 01:06 AM
Are you opening this workbook from code, or just using standard Excel?

Simon Lloyd
06-18-2009, 04:08 AM
More to Bob's query, if you are using the code i gave in one workbook and then consequently opening another from that workbook the code will not update the links or bypass the message in the newly opened workbook, the code would have to reside in the workbook you are calling.