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
' Description Populates a variable with the value labels of another 
' David Marso re:value labels 02/18/1998

Option Explicit
Sub Main
Dim objSPSSInfo As ISpssInfo,ValueLabels()
Dim varwithlabels As String, varwithoutlabels As String
Dim NumVars As Long,I As Long,J As Long, NumLabels As Long
Dim strSyntax As String
 
'Substitute your variables here (or build a dialog).
varwithlabels = "a" :varwithoutlabels="b"
 
Set objSPSSInfo = objSpssApp.SpssInfo
NumVars=objSPSSInfo.NumVariables-1
For I=0 To NumVars
    If objSPSSInfo.VariableAt(I)=varwithlabels Then
        NumLabels= objSPSSInfo.NumberOfValueLabels(I)-1
        strSyntax= "VALUE LABELS " & varwithoutlabels & " "                         
        ReDim ValueLabels(1,NumLabels)
        For J=0 To NumLabels
       	 	With objSPSSInfo
       	 	strSyntax =strSyntax & .ValueAt(I,J) & " " & Chr$(34) & .ValueLabelAt(I,J) & Chr$(34) & " "
        	End With
        Next J
        objSpssApp.ExecuteCommands(strSyntax,False)                 
        Exit For
    End If
Next I

End Sub