Macro not to update links when Opening Workbook

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,561
Office Version
  1. 2021
Platform
  1. Windows
I have the folowing Macro which opens a specific workbook and sets update Links to false

I would like the code amended so that the code can be inserted in the worksheet of the actual workbook i.e "Inventory Holdings Costs.xlsm"so that when it open the likns are not updated

Your assistance is most appreciated


Code:
 Sub OpenFile_UpdateLinksNo()
Application.Workbooks.Open Filename:="C:\my documents\Inventory holding costs", UpdateLinks:=False

End Sub
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Put this in the target workbook in its open event?

ThisWorkbook.UpdateLinks = xlUpdateLinksNever
 
Upvote 0
Thanks for the reply. What do you mean by "Put this in the target workbook in its open event?"
 
Upvote 0
You suggested putting code for this in a sheet in the workbook you want to open (the target workbook). I'm saying don't put the code in a sheet, put it at the workbook level and in the workbook open event. Then it will run when the wb opens.
 
Upvote 0
I have set up the code in this workbook as follows:

However, When Opening the File the update link message box still appears

When open the file for the first time, I do not want this message to appear

Once file is opening I then runn a macro to import data and then it will update the links

Kindly amend code accordingly

Code:
 Private Sub Workbook_Open()
ThisWorkbook.UpdateLinks = xlUpdateLinksNever
End Sub
 
Upvote 0
My understaning is that when it is placed in the Workbook_Open event it doesn't trigger until after the update has already been run.

Consider putting it in BeforeSave

VBA Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    ThisWorkbook.UpdateLinks = xlUpdateLinksNever
End Sub
 
Upvote 0
Solution
Many Thanks Alex.

code works perfectly now
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,394
Members
448,957
Latest member
Hat4Life

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