Set oFs = Server.CreateObject("Scripting.FileSystemObject")
Set oFolder = oFs.GetFolder(vServerFolder)
通过Folder对象的.Files集合的列举,可以获取文件夹下的文件,并且限制显示的文件类型为Excel。执行下面的HTML/ASP代码创建文件选择列表:
< select name="XlBook" >
< %
vOptions = ""
For Each oFile In oFolder.Files
If oFile.Type = "Microsoft Excel Worksheet" Then
vOptions = vOptions & "< option >" & _
Server.HtmlEncode(oFile.Name) & "< /option >
End If
Next
Response.Write vOptions
% >
< /select >