Library.ImportTextAuto

This function imports a text file using auto formatting.

Syntax Parameters Return Value
Function Library.ImportTextAuto( _
    fileName As String, _
    Optional fieldSeparator As Variant = 9, _
    Optional startImport As Long = 1, _
    Optional TextQualiferCode As TextImportQualifier = scTextImportQualifierNone, _
    Optional bTreatConsecutiveSeparatorsAsOne As Boolean = False, _
    Optional bCaseNamesFromFirstColumn As Boolean = False, _
    Optional bVariableNamesFromFirstRow As Boolean = False) As Spreadsheet
  • fileName [in]

The fully-qualified pathway to the text file to import.

Type: String

  • fieldSeparator [in,optional]

Which ASCII character code shall be used as a separator in the text file when importing. This parameter defaults to 9, which implies a tab.

Type: Variant

Default value: 9

  • startImport [in,optional]

The first case to begin import. This parameter defaults to 1.

Type: Long

Default value: 1

  • TextQualiferCode [in,optional]

The text qualifier. Constants that may be used as arguments for this parameter are: scTextImportQualifierNone, scTextImportQualifierDoubleQuote, scTextImportQualifierSingleQuote.

Type: TextImportQualifier

Default value: scTextImportQualifierNone

  • bTreatConsecutiveSeparatorsAsOne [in,optional]

Whether to treat consecutive separators as a single separator. This parameter defaults to False.

Type: Boolean

Default value: False

  • bCaseNamesFromFirstColumn [in,optional]

Whether or not to import the first column in the text file as the case names. This parameter defaults to False.

Type: Boolean

Default value: False

  • bVariableNamesFromFirstRow [in,optional]

Whether or not to import the first row in the text file as the variable names. This parameter defaults to False.

Type: Boolean

Default value: False

Spreadsheet

SVB Example

Importing text:

Option Base 1
Option Explicit
Sub Main
    Dim S1 As Spreadsheet
    'assigns the spreadsheet heart.sta to the spreadsheet object s1
    Set S1 = Open(Path & "\Examples\Datasets\Heart.sta")
    'saves the spreadsheet as a text file
    'file saved as heart.txt
    s1.ExportText(Path & "\Heart.txt",1,0,1,0,9,True,False,False,True)
    Dim s2 As Spreadsheet
    'imports heart.txt
    Set s2 = Application.ImportTextAuto(Path & _
    "\Heart.txt",9,1,scTextImportQualifierNone,False,False,False)
    'sets the spreadsheet to visible
    s2.Visible = True
End Sub