'Begin Description 'This script changes the column width of the data editor to match the 'number of characters in each variables. Overiding minimum and maximum 'values are defined immediately before the "Option Explicit" line 'The actual content of the variables are left unchanged 'Raynald Levesque 2002/05/23 'http://pages.infinit.net/rlevesqu/index.htm 'End Description ' Define min and max column width Const IntMinLength As Integer = 7 Const IntMaxLength As Integer = 15 Option Explicit Sub Main Dim objDocuments As ISpssDocuments Dim objDataDoc As ISpssDataDoc Dim objSpssInfo As ISpssInfo Dim varName As String Dim varList As String Dim intLength As Integer Dim i As Integer Set objDocuments = objSpssApp.Documents 'Open data document if one is already open If objDocuments.DataDocCount <> 0 Then Set objDataDoc = objDocuments.GetDataDoc(0) objDataDoc.Visible=True Set objSpssInfo = objSpssApp.SpssInfo 'Get the number of variables Dim varCount As Integer varCount = objSpssInfo.NumVariables If varCount = 0 Then End End If With objSpssInfo For i = 0 To varCount - 1 varName = .VariableAt(i) 'Uncomment next line if you only want to change column width of strings 'If .VarType(i) = SpssDataString Then ' Comment next line if you only want to change column width of strings If 1=1 Then 'Make column width of length of this string variable '(subject to the min and max specified above) intLength = .VarLength(i) If IntMaxLength < .VarLength(i) Then intLength = IntMaxLength If IntMinLength > .VarLength(i) Then intLength = IntMinLength objSpssApp.ExecuteCommands ("VARIABLE WIDTH " & varName & " (" & intLength & ").",True) End If Next End With End If Set objDataDoc = Nothing Set objDocuments = Nothing End Sub