Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Open the VBA Editor of Excel and type this in the Immediate Window (See Screenshot)</p> <pre><code>Application.AskToUpdateLinks = False </code></pre> <p>Close Excel and then open your File. It will not prompt you again. Remember to reset it when you close the workbook else it will not work for other workbooks as well.</p> <p><strong>ScreenShot</strong>:</p> <p><img src="https://i.stack.imgur.com/CxP23.png" alt="enter image description here"></p> <p><strong>EDIT</strong></p> <p>So applying it to your code, your code will look like this</p> <pre><code>Function getWorkbook(bkPath As String) As Workbook Application.AskToUpdateLinks = False Set getWorkbook = Workbooks.Open(bkPath, False) Application.AskToUpdateLinks = True End Function </code></pre> <p><strong>FOLLOWUP</strong></p> <p>Sigil, The code below works on files with broken links as well. Here is my test code.</p> <p>Test Conditions</p> <ol> <li>Create 2 new files. Name them <code>Sample1.xlsx</code> and <code>Sample2.xlsx</code> and save them on <code>C:\</code></li> <li>In cell <code>A1</code> of <code>Sample1.xlsx</code>, type this formula <code>='C:\[Sample2.xlsx]Sheet1'!$A$1</code></li> <li>Save and close both the files</li> <li>Delete Sample2.xlsx!!!</li> <li>Open a New workbook and it's module paste this code and run <code>Sample</code>. You will notice that you will not get a prompt.</li> </ol> <p><strong>Code</strong></p> <pre><code>Option Explicit Sub Sample() getWorkbook "c:\Sample1.xlsx" End Sub Function getWorkbook(bkPath As String) As Workbook Application.AskToUpdateLinks = False Set getWorkbook = Workbooks.Open(bkPath, False) Application.AskToUpdateLinks = True End Function </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload