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
' Demo: this script lists all files (meeting a given mask eg *.spo) located in a given folder 
' rlevesque@videotron.ca 2001/09/12
' http://pages.infinit.net/rlevesqu/index.htm
Option Explicit

Sub Main
	Dim strPath As String
	Dim strFilemask As String
	strPath="c:\\program files\\spss\\"
	strFileMask="*.sav"
	'First example
	Call GetListOfFiles(strPath, strFileMask)
	'Second example
	Call GetListOfFiles("c:\\program files\\spss\\","g*.sav")
	
'	Call GetListOfFiles("", "")
End Sub

Sub GetListOfFiles (strPath As String, strFileMask As String)
Dim strFname As String
Dim strHeading As String		'Heading of MsgBox

	If InStr(strPath, "\\") = 0 Then		'no path given, use current folder
		strPath = objSpssApp.GetSPSSPath
	End If
	If Len(strFileMask) = 0 Then 		'no file Mask given, show all files
		strFileMask = "*.*"
	End If

	strHeading = "List of " & strFileMask & " files in " & vbCr & StrPath
    'Get the first file name
    strFname = Dir$(strPath & strFileMask)
    While strFname <> ""
        If MsgBox (strFname,vbOkCancel,strHeading) = vbOK Then 
		    	'Get the next file name
	        strFname = Dir$()
        Else	'exit
    	    strFname = ""
        End If
    Wend 
End Sub