title: excel vba open workbook
body: <p>My code is:</p>
  
  <pre><code>Dim wb As Workbook
  Dim MyObj As Object, MySource As Object, file As Variant
  file = Dir("C:\Users\dlf164\Desktop\NE\")
  While (file &lt;&gt; "")
      If InStr(file, a) &gt; 0 Then
          Set wb = Workbooks.Open(file)
  
      End If
  file = Dir
  Wend
  </code></pre>
  
  <p>The error which I am receiving is <em>Application or object defined  runtime error</em>. </p>
  
  <p>How to solve this?</p>