title: .Attachments.Add on the file that is running the code
body: <p>I've code that has been working for over a year that has stopped working.</p>
  <p>When I try to add the current file as an attachment to an Outlook email it throws an error saying that the file is already open or I don't have permission to access it.</p>
  <blockquote>
  <p>Run-Time error '-2147024864 (80070020')</p>
  </blockquote>
  <p>-If I attach the same file (so the file being attached is closed) from a different macro it works, showing (I believe) that it isn't a permission issue.</p>
  <p>-The file is located in my OneDrive folder. If I pull it out on the desktop it works. Points to OneDrive being the issue.</p>
  <p>-If I create a new file, save it in the OneDrive folder and paste the below code into a module it works. If I then close the file and reopen it, the issue returns.</p>
  <p>-I have over 10 computers that have this issue that are on Excel Build 9001.2144.<br />
  I have one computer (same model computer as some that aren't working) that is on Build 8730.2127 that doesn't have the issue. All computers have the same OneDrive build, 17.3.7294.0108.</p>
  <p>-I took one computer that wasn't working and reverted to Build 8730.2127 and it worked. Seems something changed in the update related to how OneDrive and Excel are interacting.</p>
  <p>The problem line is:</p>
  <pre><code>.Attachments.Add ThisWorkbook.FullName
  </code></pre>
  <p>In my research it seems that attaching the active file/active workbook is common.</p>
  <pre class="lang-vb prettyprint-override"><code>Dim OutApp As Object, OutMail As Object
  
  Set OutApp = CreateObject(&quot;Outlook.Application&quot;)
  Set OutMail = OutApp.CreateItem(0)
  With OutMail
      .To = &quot;&quot;
      .CC = &quot;&quot;
      .BCC = &quot;&quot;
      .Subject = &quot;&quot;
      .Body = &quot;&quot;
      .Attachments.Add ThisWorkbook.FullName
      .Display
  End With
  
  Set OutMail = Nothing
  Set OutApp = Nothing
  </code></pre>