title: Facing issue while extracting data from MS Excel using Visual Basic
body: <p>I have written below code to generate data into notepad format from MS excel using VB code.
  I am getting the file in notepad but problem is that if there are multiple sheet in the excel then also I am getting a single extract. I want to get the extract of all the sheet in a diff file.</p>
  
  <p>please suggest.</p>
  
  <pre><code>Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" _
  (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
  
  Private Const MAX_PATH As Long = 260
  
  '~~&gt; Change this where and how you want to save the file
  Const FlName = "C:\My\excel\MyWorkbook.vbs"
  
  Sub Sample()
      Dim tmpFile As String
      Dim MyData As String, strData() As String
      Dim entireline As String
      Dim filesize As Integer
  
      '~~&gt; Create a Temp File
      tmpFile = "C:\My\excel\Sheet1.vbs"
  
      ActiveWorkbook.SaveAs Filename:=tmpFile _
      , FileFormat:=xlText, CreateBackup:=False
  
      '~~&gt; Read the entire file in 1 Go!
      Open tmpFile For Binary As #1
      MyData = Space$(LOF(1))
      Get #1, , MyData
      Close #1
      strData() = Split(MyData, vbCrLf)
  
      '~~&gt; Get a free file handle
      filesize = FreeFile()
  
      '~~&gt; Open your file
      Open FlName For Output As #filesize
  
      For i = LBound(strData) To UBound(strData)
          entireline = Replace(strData(i), """", "")
          '~~&gt; Export Text
          Print #filesize, entireline
      Next i
  
      Close #filesize
  
      MsgBox "Done"
  End Sub
  
  'Function TempPath() As String
      'TempPath = String$(MAX_PATH, Chr$(0))
      'GetTempPath MAX_PATH, TempPath
      'TempPath = Replace(TempPath, Chr$(0), "")
  'End Function
  </code></pre>