VBA solution to get rid of "update" links message when a file is opened?

Mr2017

Well-known Member
Joined
Nov 28, 2016
Messages
644
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi

I get two different types of messages when opening certain files with a macro, that I don't want to get.

One of them says

"This workbook contains links to one or more sources that could be unsafe.

If you trust the links, update them, to get the latest data...."

Then it gives you buttons that say "Update," "Don't update," and "Help."

I'd like the macro to either remove this message from appearing or click on "Don't update."

Does anyone know what the code is?

TIA
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Hi Paul

Thanks for the response.

Do you know where I should put that code to make it work?

I've tried to put it in the code below, but it hasn't worked, as expected.

It's commented out, at the moment (there's an apostrophe before it):

Code:
Sub OpenFile(file_name)
 
Application.ScreenUpdating = False
 
This_Bk = ActiveWorkbook.Name
Application.EnableEvents = False
Workbooks.Open (file_name)
NewFile = ActiveWorkbook.Name
 
Application.EnableEvents = True
'Application.Workbooks.Open FileName:="NewFile", UpdateLinks:=False
Workbooks(NewFile).Activate
Worksheets("Sheet1").Select
 
Upvote 0
Sorry for delay, been working!

That code doesn't make sense. It opens a file 'file_name', which has been passed to the sub then gives 'NewFile' the same name and tries to open it again!

Do you mean:
Code:
Sub OpenFile(file_name)
    Application.ScreenUpdating = False 
    Application.EnableEvents = False
    Workbooks.Open (file_name), UpdateLinks:=False
    Worksheets(1).Select
    Application.EnableEvents = True
End Sub

If I had an idea of what you are trying to achieve then maybe I, or someone else, could give you the correct answer.
 
Upvote 0
Excellent! Thank you Paul Ked !

Yes - that's what I was trying to do!

I didn't know that you could just add the "
UpdateLinks:=False" code after opening the file and separating the code with a comma!

This is really useful!

Thanks ever so much!!
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,387
Members
449,080
Latest member
Armadillos

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