' This script asks for the Fiscal Year, then defines the macro !fy which gives the Fiscal Year. ' It then calls a syntax file. ' Usage: ' Change the script to refer to the path and sps file name ' Change the minimum and max allowed fiscal year ' The syntax file must be adjusted to use !fy whenever fiscal year is required ' For instance the following syntax works: ' * report.sps. 'DATA LIST LIST /a. 'Begin DATA '1 'End DATA. 'LIST. 'COMPUTE Year=!fy. 'LIST. ' http://pages.infinit.net/rlevesqu/SampleScripts.htm ' Raynald Levesque 2002/11/08 Option Explicit Sub Main() Dim objSyntaxDoc As ISpssSyntaxDoc Dim strFY As String Dim CmdStr As String On Error GoTo Oopps Do 'Last number in InputBox is the default value strFY = InputBox$("Must be an integer between 1980 and 2002","Enter the Fiscal Year:","2001") Loop Until CInt(strFY)>1980 And CInt(strFY)<2002 'Define a macro then run it CmdStr = "DEFINE !fy()" & strFY & "!ENDDEFINE." & vbCr objSpssApp.ExecuteCommands CmdStr,True 'Open syntax file and run it Set objSyntaxDoc = objSpssApp.OpenSyntaxDoc ("c:\\temp\\report.sps") objSyntaxDoc.Visible=True objSyntaxDoc.Run objSyntaxDoc.Close Set objSyntaxDoc = Nothing Exit Sub Oopps: MsgBox "Following error occured: " & Err.Description End Sub