title: Close a file in vba after using Application.GetOpenFilename
body: <p>I'm running analyses of reinforced concrete buildings in a software called OpenSees. The results of the analyses are written in txt files, so in order to analyse these results I read and write the txt files into Excel using a vba. There is no problem to write the data the first time.</p>
  
  <p>My problem raises when after having the txt files written into Excel for the first time I try to run OpenSees a second time without closing Excel. Opensees points out that the txt files are opened and so it can not overwrite them. I supposed after using Close #1 the files were closed.</p>
  
  <p>What I have to do so far is run OpenSees 1st time, use vba to write the results in Excel, save and close Excel, run OpenSees 2nd time, ... and so on.</p>
  
  <p>The main code I am using to write the files is</p>
  
  <pre><code>ruta1 = Application.GetOpenFilename("text Files (*.out),*.out", MultiSelect:=True)
  If Not IsEmpty(ruta1) Then
  
      For i = LBound(ruta1) To UBound(ruta1)
  
          Open ruta1(i) For Input As #1
  
          Do Until EOF(1)
              Line Input #1, linea
              valor = Split(linea, " ") ' valor(i) : 0 time - 1 Ux - 2 Uy - 3 Rz
              h5.Cells(f_elong + j, c_elong) = valor(1) / hw * 100
              h5.Cells(f_elong + j, c_elong + 1) = valor(2) / lw * 100
              h6.Cells(f_FD + j, c_FD) = valor(1) / hw * 100
              j = j + 1
          Loop
  
          Close #1
  
      Next
  
  End If
  </code></pre>