Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

runtime error 438 1

Status
Not open for further replies.

din2005

Programmer
Mar 22, 2005
162
GB
Hi i get this error msg saying runtime error 438. The code points out to line highlighted red.... any suggestions how i could solve this?

Dim fso As Object
Dim myFolder As Object
Dim AllFolders As Object
Dim curFolder As Object

Set fso = CreateObject("Scripting.FileSystemObject")
Set myFolder = fso.GetFolder("C:\image")
Set AllFolders = myFolder.Folders

For Each curFolder In AllFolders
If curFolder.Name Like "[a-z][a-z]####" Then
Debug.Print curFolder.Name
Else
fso.DeleteFolder curFolder.Name
End If
Next
Set AllFolders = Nothing
Set myFolder = Nothing
Set fso = Nothing


many thanks
 
Try:

[tt]Set AllFolders = myFolder.SubFolders[/tt]

Roy-Vidar
 
Thanks roy...

that worked but further along it says path not found... on the line highlighted red do u know what could be wrong

Dim fso As Object
Dim myFolder As Object
Dim AllFolders As Object
Dim curFolder As Object

Set fso = CreateObject("Scripting.FileSystemObject")
Set myFolder = fso.GetFolder("C:\image")
Set AllFolders = myFolder.SubFolders
For Each curFolder In AllFolders
If curFolder.Name Like "[a-z][a-z]####" Then
Debug.Print curFolder.Name
Else
fso.DeleteFolder curFolder.Name
End If
Next
Set AllFolders = Nothing
Set myFolder = Nothing
Set fso = Nothing
 
I think the DeleteFolder method accepts the path of the folder to delete.

[tt]fso.DeleteFolder curFolder.Path [/tt]

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top