Click to See Complete Forum and Search --> : displaying filenames from same folder in different cells


blodefood
10-24-2003, 09:44 AM
I have six Excel spreadsheets in a folder. I would like to display the three filenames as hyperlinks that start with W in one table cell and the ones that start with M in the other table cell.

My code (see below) successfully displays ALL the files in the folder, but only in one table cell. I need a second code to go in the second table cell to display the M files. I have commented my code, so I trust this helps to define better what I am trying to accomplish.

Help is always appreciated.

Thanks,
blodefood
:D

<table>
<tr>
<td>

<%dim strPath

strPath = "D://Wwwroot/test/ID01/"

dim oFS, oFile, oFolder, oFolderContents, slot, variablename
varname=left(oFile,1)

Set oFS = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFS.getFolder(strPath)

for each oFile in oFolder.files

'create function to read first char in filename
'if filename starts with W then display in weekly column
'if filename starts with M then display in monthly column

%>

'This code creates the list of hyperlinks to each of the files.

<A href="<%response.write oFile.Name%>">
<%response.write oFile.Name%></a><br>
</td>


<td>
<%'I need the second code for the M files here.
%>
</td>
</tr>
</table>

rdoekes
10-24-2003, 01:14 PM
Dim strWeekly, strMonthly
...
For Each oFile In oFolder.files
If Left(oFile.Name, 1) = "W" Then
strWeekly = strWeekly & _
"<a href=""" & oFile.Name & """>" & _
oFile.Name & "</a><br>"
ElseIf Left(oFile.Name, 1) = "M" Then
strMonthly = strMonthly & _
"<a href=""" & oFile.Name & """>" & _
oFile.Name & "</a><br>"
End If
Next
%>
<tr>
<td><% = strWeekly%></td>
<td><% = strMontly%></td>
</tr>
hope this helps,

-Rogier Doekes

blodefood
10-24-2003, 01:34 PM
Beautiful!

Thanks for your help!

:D

blodefood