title: Two ways to write to text file using Excel VBA: Microsoft Standard Library vs Microsoft Scripting Runtime
body: <p>I found there is two ways of creating and writing to a text file in Excel VBA: by using microsoft standard library or by using Microsoft Scripting Runtime. Are they equivalent? Below we have examples of both.</p>
  
  <pre><code>Sub WriteToTextFile_FirstWay()
      Open "D:\Temp1.txt" For Output As #1
          Print #1, "This text file was created using microsoft standard library."
      Close #1
  End Sub
  
  Sub WriteToTextFile_SecondWay()
      Dim FSO As New FileSystemObject
      Set txtstream = FSO.CreateTextFile("D:\Temp2.txt", True, True)
      txtstream.Write "This text file was created using Microsoft Scripting Runtime."
      txtstream.Close
  End Sub
  </code></pre>