1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'This shows how to obtain information on the current data file. This script
'   -displays the number of variables in the Designated Output Window
'   -displays the number of cases in a MsgBox
'http://pages.infinit.net/rlevesqu/index.htm

Sub Main
Dim strDataName As String		'Name of data file
Dim varNumVars As Variant 		'number of variables
Dim strContent As String
Dim lngNumCases As Long			'Number of cases
    With objSpssApp.Documents.GetDataDoc(0)
		strDataName = .GetBannerText
		varNumVars = .GetNumberOfVariables
		strContent = strDataName & " has " & varNumVars & " Variables."
		' Display the number of variables in the Output Window
        objSpssApp.GetDesignatedOutputDoc.InsertTitle("Variable Count",strContent)
        
        lngNumCases = .GetNumberOfCases
        ' Display the number of cases in a msg box
        MsgBox "There are " & lngNumCases  & " cases in the file."
    End With
End Sub