1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
'To export labels to txt files.

'If you run this script With a datafile opened, the Variable and Value labels will be copied
'and placed in 3 .txt-files on the C:\\ -disc . The fields in this txt files are seperated
'by the "|" symbol.
'Author unknown

Option Explicit
Sub Main
Dim objSPSSInfo As ISpssInfo,ValueLabels()
Dim NumVars As Long, LongValString As String, NumVals As Long, K As Long,I As Long,J As Long, VarName As String, VarLabel As String, ValName As String, ValLabel As String
 
Set objSPSSInfo = objSpssApp.SpssInfo
NumVars=objSPSSInfo.NumVariables-1
Open "C:\\variable label.txt" For Output As #1
Open "C:\\value label.txt" For Output As #2
Open "C:\\overview.txt" For Output As #3
 
For I=0 To NumVars
  VarName= objSPSSInfo.VariableAt(I)
  VarLabel= objSPSSInfo.VariableLabelAt(I)
  If Len(VarLabel)=0 Then 
      VarLabel=VarName
  End If
  Print #1, VarName & "|" & VarLabel 
  LongValString = CStr(VarName) & "|" & CStr(VarLabel)
  NumVals= objSPSSInfo.NumberOfValueLabels(I)-1
  For K=0 To NumVals
      ValName= objSPSSInfo.ValueAt(I,K)
      ValLabel= objSPSSInfo.ValueLabelAt(I,K)
      If Len(ValLabel)=0 Then
           ValLabel=ValName
      End If
      Print #2, VarName & "|" & ValName & "|" & ValLabel
      LongValString = LongValString & "|" & CStr(ValName) & "|" & CStr(ValLabel)
  Next K
  Print #3, LongValString
Next I
Set objSPSSInfo = Nothing
Close #1
Close #2
Close #3
End Sub