C
Chris Kinata
Hi all,
Having a memory lapse I guess. I'm working on a function
that's supposed to return a list of only the .htm files in the same
folder that contains the active document.
Following is a condensed version of the function.
The var oWebFiles is a collection of all the files in the folder.
The For...Next loop checks the file extension of each file,
and if not .htm, removes it from the collection.
OK, here's the problem. As it appears here, the .Delete method
deletes not its entry in the collection, but the file itself.
Have also tried this with the Remove method with the same
result.
without deleting the file?
Thanks!
=====
Function CurrFolderFiles(sFileExt As String) As WebFiles
Dim oWebFile As WebFile
Dim oThisWebFile As WebFile
Dim oWebFolder As WebFolder
Dim oWebFiles As WebFiles
Dim sThisWebFileName As String
Set oWebFile = ActivePageWindow.File
Set oWebFolder = oWebFile.Parent
Set oWebFiles = oWebFolder.Files
For Each oThisWebFile In oWebFiles
sThisWebFileName = oThisWebFile.Name
'If the file extension <> requested extension, delete from collection.
If Right(sThisWebFileName, Len(sFileExt)) <> sFileExt Then
oWebFiles.Delete (sThisWebFileName)
Else
'do something else
End If
Next
Set CurrFolderFiles = oWebFiles
'set vars to nothing...
End Function
Having a memory lapse I guess. I'm working on a function
that's supposed to return a list of only the .htm files in the same
folder that contains the active document.
Following is a condensed version of the function.
The var oWebFiles is a collection of all the files in the folder.
The For...Next loop checks the file extension of each file,
and if not .htm, removes it from the collection.
OK, here's the problem. As it appears here, the .Delete method
deletes not its entry in the collection, but the file itself.
Have also tried this with the Remove method with the same
result.
without deleting the file?
Thanks!
=====
Function CurrFolderFiles(sFileExt As String) As WebFiles
Dim oWebFile As WebFile
Dim oThisWebFile As WebFile
Dim oWebFolder As WebFolder
Dim oWebFiles As WebFiles
Dim sThisWebFileName As String
Set oWebFile = ActivePageWindow.File
Set oWebFolder = oWebFile.Parent
Set oWebFiles = oWebFolder.Files
For Each oThisWebFile In oWebFiles
sThisWebFileName = oThisWebFile.Name
'If the file extension <> requested extension, delete from collection.
If Right(sThisWebFileName, Len(sFileExt)) <> sFileExt Then
oWebFiles.Delete (sThisWebFileName)
Else
'do something else
End If
Next
Set CurrFolderFiles = oWebFiles
'set vars to nothing...
End Function