Wildcard in pathname?

Scaniafan

Registered User.
Local time
Today, 06:23
Joined
Sep 30, 2008
Messages
82
Hello all,

I'm trying to make a script that deletes a folder when I click a button. I'm using below code where the * translates to a weeknumber. At least, it should.

If I change the * to the weeknumber (e.g. "Week 27") the folder is deleted.

I think I'm using the wrong build-up with the wildcard, but I can't seem to find the correct way... Anybody able to help me out here?

Code:
Dim FSO As Object
 Dim MyPath As String
  Set FSO = CreateObject("scripting.filesystemobject")
   MyPath = "[I]pathname[/I]\Week [B]*[/B]\"   '<< Change
                
  If Right(MyPath, 1) = "\" Then
   MyPath = Left(MyPath, Len(MyPath) - 1)
  End If

  If FSO.FolderExists(MyPath) = False Then
     MsgBox MyPath & " doesn't exist"
  Exit Sub

 End If

FSO.deletefolder MyPath
 
Dim FSO As Object
Dim MyPath As String
Dim myFolder As String
Dim sResult as string
Set FSO = CreateObject("scripting.filesystemobject")
MyPath = "pathname\"
MyFolder = "Week *"

sResult = Dir(Mypath & MyFolder, vbDirectory)
If sResult <> "" Then
While sResult <> ""
FSO.deletefolder MyPath
sResult = Dir()
Wend
Else
MsgBox MyPath & " doesn't exist"
End If
Set FSO=Nothing
 
Had to make one small change:

Code:
FSO.deletefolder MyPath & sResult

and it works like a charm. Thanks!
 

Users who are viewing this thread

Back
Top Bottom