title: Creating a Tab Delimited Text File Manually in vba
body: <p>I am trying to create tab delimited text file using vba in Access. This file is essentially reading data from tables and has a few bits of strings of text at the start of the file. The purpose of this is to create a Shared Parameter text file that can be read in another software (Autodesk Revit)</p>
  
  <p>The problem I am having is what I export doesn't seem be a tab delimited file. I can test this by trying to import this into excel and it does not recognize it as a tab delimited file.</p>
  
  <p>The snippet below shows what I have coded up. Running it and then trying to import in Excel, shows that it is not read as a tab delimited file. For convenience I have commented out sections that read the database as it is not relevant to the actual problem.</p>
  
  <pre><code>Public Function ExportRevitSharedParameterFile()
  
      Dim rst As DAO.Recordset
  
      Dim header As String
      Dim metaHeader As String
      Dim groupHeader As String
      Dim paramHeader As String
  
      Dim metaData As String
      Dim groupData As String
      Dim paramData As String
  
      header = "# This is a Revit shared parameter file." &amp; vbCrLf &amp; "# Do not edit manually."
      metaHeader = "*META" &amp; vbTab &amp; "VERSION" &amp; vbTab &amp; "MINVERSION"
      groupHeader = "*GROUP" &amp; vbTab &amp; "ID" &amp; vbTab &amp; "NAME"
      paramHeader = "*PARAM" &amp; vbTab &amp; "GUID" &amp; vbTab &amp; "NAME" &amp; vbTab &amp; "DATATYPE" &amp; vbTab &amp; "DATACATEGORY" &amp; vbTab &amp; "GROUP" &amp; vbTab &amp; "VISIBLE" &amp; vbTab &amp; "DESCRIPTION" &amp; vbTab &amp; "USERMODIFIABLE"
  
      Set fs = CreateObject("Scripting.FileSystemObject")
  
      ' This path may need to be changed to an appropriate location with permission access
      Set a = fs.CreateTextFile("C:\sp.txt", True, True)
  
      a.WriteLine (header)
      a.WriteLine (metaHeader)
  
      metaData = "META" &amp; vbTab &amp; "2" &amp; vbTab &amp; "1"
      a.WriteLine (metaData)
  
      a.WriteLine (groupHeader)
      'Write some data from an access table
      'Set rst = CurrentDb.OpenRecordset("SP File - Groups", dbOpenSnapshot)
      'Do While Not rst.EOF
      '    groupData = "GROUP" &amp; vbTab &amp; rst![Group ID] &amp; vbTab &amp; rst![Group Name]
      '    a.WriteLine (groupData)
      '    rst.MoveNext
      'Loop
      'rst.Close
      'Set rst = Nothing
  
      a.WriteLine (paramHeader)
      'Write some data from an access table
      'Set rst = CurrentDb.OpenRecordset("SP File - Parameters", dbOpenSnapshot)
      'Do While Not rst.EOF
      '    paramData = "PARAM" &amp; vbTab &amp; rst![Parameter GUID] &amp; vbTab &amp; rst!Name &amp; vbTab &amp; rst![Revit Type] &amp; vbTab &amp; "" &amp; vbTab &amp; rst![Group ID] &amp; vbTab &amp; "1" &amp; vbTab &amp; "" &amp; vbTab &amp; "1"
      '    a.WriteLine (paramData)
      '    rst.MoveNext
      'Loop
      'rst.Close
      'Set rst = Nothing
  
      a.Close
  
  End Function
  </code></pre>
  
  <p>Any help on this will be appreciated. I am obviously missing some info on how tab delimited files are created.</p>