Library.ImportTextFixed

This function imports a text file using fixed formatting.

Syntax Parameters Return Value
Function Library.ImportTextFixed( _
    fileName As String, _
    NbVars As Long, _
    NbCases As Long, _
    Optional startImport As Long = 1, _
    Optional formatStatement As String = "", _
    Optional bCaseNamesFromFirstColumn As Boolean = False) As Spreadsheet
  • fileName [in]

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

Type: String

  • NbVars [in]

How many variables to import.

Type: Long

  • NbCases [in]

How many cases to import.

Type: Long

  • startImport [in,optional]

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

Type: Long

Default value: 1

  • formatStatement [in,optional]

The format to apply when importing.

Type: String

Default value: ""

  • 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

Spreadsheet

SVB Example

Importing fixed 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.ImportTextFixed(Path & _
    "\Heart.txt",3,3,1,,False)
    'sets the spreadsheet to visible
    s2.Visible = True
End Sub