Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>UPDATE:</strong></p> <p>After all the details summarized and discussed, I spent 2 fair hours in checking the options, and this update is to dot all <code>i</code>s.</p> <h2>Preparations</h2> <p>First of all, I performed a clean Office 2010 x86 install on Clean Win7 SP1 Ultimate x64 virtual machine powered by VMWare (this is usual routine for my everyday testing tasks, so I have many of them deployed).</p> <p>Then, I changed only the following Excel options (i.e. all the other are left as is after installation):</p> <ul> <li><code>Advanced &gt; General &gt; Ask to update automatic links</code> <strong>checked</strong>:</li> </ul> <p><img src="https://i.stack.imgur.com/oVl8R.png" alt="Ask to update automatic links"></p> <ul> <li><code>Trust Center &gt; Trust Center Settings... &gt; External Content &gt; Enable All...</code> (although that one that relates to Data Connections is most likely not important for the case):</li> </ul> <p><img src="https://i.stack.imgur.com/bAefH.png" alt="External Content"></p> <h2>Preconditions</h2> <p>I prepared and placed to <code>C:\</code> a workbook exactly as per <code>@Siddharth Rout</code> suggestions in his updated answer (shared for your convenience): <a href="https://www.dropbox.com/s/mv88vyc27eljqaq/Book1withLinkToBook2.xlsx" rel="noreferrer">https://www.dropbox.com/s/mv88vyc27eljqaq/Book1withLinkToBook2.xlsx</a> Linked book was then <strong>deleted</strong> so that link in the shared book is unavailable (for sure).</p> <h2>Manual Opening</h2> <p>The above shared file shows on opening (having the above listed Excel options) 2 warnings - in the order of appearance:</p> <p><strong>WARNING #1</strong></p> <p><img src="https://i.stack.imgur.com/JH2KW.png" alt="This workbook contains links to other data sources"></p> <p>After click on <code>Update</code> I expectedly got another:</p> <p><strong>WARNING #2</strong></p> <p><img src="https://i.stack.imgur.com/oHzhX.png" alt="This workbook contains one or more links that cannot be updated"></p> <p>So, I suppose my testing environment is now pretty much similar to <code>OP</code>'s) So far so good, we finally go to</p> <h2>VBA Opening</h2> <p>Now I'll try all possible options step by step to make the picture clear. I'll share only relevant lines of code for simplicity (complete sample file with code will be shared in the end).</p> <p><strong>1. Simple Application.Workbooks.Open</strong></p> <pre><code>Application.Workbooks.Open Filename:="C:\Book1withLinkToBook2.xlsx" </code></pre> <p>No surprise - this produces BOTH warnings, as for manual opening above.</p> <p><strong>2. Application.DisplayAlerts = False</strong></p> <pre><code>Application.DisplayAlerts = False Application.Workbooks.Open Filename:="C:\Book1withLinkToBook2.xlsx" Application.DisplayAlerts = True </code></pre> <p>This code ends up with <strong>WARNING #1</strong>, and either option clicked (<code>Update</code> / <code>Don't Update</code>) produces NO further warnings, i.e. <code>Application.DisplayAlerts = False</code> suppresses <strong>WARNING #2</strong>.</p> <p><strong>3. Application.AskToUpdateLinks = False</strong></p> <pre><code>Application.AskToUpdateLinks = False Application.Workbooks.Open Filename:="C:\Book1withLinkToBook2.xlsx" Application.AskToUpdateLinks = True </code></pre> <p>Opposite to <code>DisplayAlerts</code>, this code ends up with <strong>WARNING #2</strong> only, i.e. <code>Application.AskToUpdateLinks = False</code> suppresses <strong>WARNING #1</strong>.</p> <p><strong>4. Double False</strong></p> <pre><code>Application.AskToUpdateLinks = False Application.DisplayAlerts = False Application.Workbooks.Open Filename:="C:\Book1withLinkToBook2.xlsx" Application.DisplayAlerts = True Application.AskToUpdateLinks = True </code></pre> <p>Apparently, this code ends up with suppressing <strong>BOTH WARNINGS</strong>.</p> <p><strong>5. UpdateLinks:=False</strong></p> <pre><code>Application.Workbooks.Open Filename:="C:\Book1withLinkToBook2.xlsx", UpdateLinks:=False </code></pre> <p>Finally, this 1-line solution (originally proposed by <code>@brettdj</code>) works the same way as Double False: <strong>NO WARNINGS</strong> are shown!</p> <h2>Conclusions</h2> <p>Except a good testing practice and very important solved case (I may face such issues everyday while sending my workbooks to 3rd party, and now I'm prepared), 2 more things learned:</p> <ol> <li>Excel options DO matter, regardless of version - especially when we come to VBA solutions.</li> <li>Every trouble has short and elegant solution - together with not obvious and complicated one. Just one more proof for that!)</li> </ol> <p>Thanks very much to everyone who contributed to the solution, and especially OP who raised the question. Hope my investigations and thoroughly described testing steps were helpful not only for me)</p> <p>Sample file with the above code samples is shared (many lines are commented deliberately): <a href="https://www.dropbox.com/s/9bwu6pn8fcogby7/NoWarningsOpen.xlsm" rel="noreferrer">https://www.dropbox.com/s/9bwu6pn8fcogby7/NoWarningsOpen.xlsm</a></p> <p><strong>Original answer</strong> (tested for <strong>Excel 2007</strong> with certain options):</p> <p>This code works fine for me - it loops through ALL Excel files specified using wildcards in the <code>InputFolder</code>:</p> <pre><code>Sub WorkbookOpening2007() Dim InputFolder As String Dim LoopFileNameExt As String InputFolder = "D:\DOCUMENTS\" 'Trailing "\" is required! LoopFileNameExt = Dir(InputFolder &amp; "*.xls?") Do While LoopFileNameExt &lt;&gt; "" Application.DisplayAlerts = False Application.Workbooks.Open (InputFolder &amp; LoopFileNameExt) Application.DisplayAlerts = True LoopFileNameExt = Dir Loop End Sub </code></pre> <p>I tried it with books with unavailable external links - no warnings.</p> <p>Sample file: <a href="https://www.dropbox.com/s/9bwu6pn8fcogby7/NoWarningsOpen.xlsm" rel="noreferrer">https://www.dropbox.com/s/9bwu6pn8fcogby7/NoWarningsOpen.xlsm</a></p>
    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