title: excel 2010 vba, path/file access error
body: <p>In the below <code>excel 2010 vba</code> if the answer the the prompt is no then the files in te folder, then the folder are deleted.  However, I am getting a <code>path/file access error</code> when I run the <code>vba</code>.  Specifically the <code>RmDir MyFolder</code> line is highlighted, but when I step-through the code the correct directory appears in the variable <code>MyFolder</code> and I can write new files to the directory.  What am I missing?  Thank you :). </p>
  
  <p>Also, if I manually navigate to the directory, I can remove it.</p>
  
  <pre><code>iYesNo = MsgBox("Do the patients and barcode match the setup sheet?", vbYesNoCancel)
        Select Case iYesNo
               Case vbYes
               GoTo Line2
               Case vbNo
               MsgBox ("Doesn't match! Please enter again")
               MyFolder = Directory ' delete all txt files in the folder
               MyFile = Dir(MyFolder &amp; "*.*")
               Do Until MyFile = ""
               Kill MyFile
               MyFile = Dir
               Loop
  
                 RmDir MyFolder  ' delete folder
               GoTo Line1
         End Select
  </code></pre>