请将下列函数放到代码的模块中,然后在窗体的某个按钮的单击事件中写调用代码:
Shell_MakeFolderStructure("C:\Temp\Test1\Test2\Test3")
Function Shell_FolderExist(sFolder As Variant) As Boolean
On Error GoTo Error_Handler
Dim oShell As Object
Dim oFolder As Object
Set oShell = CreateObject("Shell.Application")
Set oFolder = oShell.NameSpace(sFolder)
If Not oFolder Is Nothing Then Shell_FolderExist = True
Error_Handler_Exit:
On Error Resume Next
Set oFolder = Nothing
Set oShell = Nothing
Exit Function
Error_Handler:
MsgBox "The following error has occurred" & vbCrLf & vbCrLf & _
"Error Source: Shell_FolderExist" & vbCrLf & _
"Error Number: " & Err.Number & vbCrLf & _
"Error Description: " & Err.Description & _
Switch(Erl = 0, "", Erl <> 0, vbCrLf & "Line No: " & Erl) _
, vbOKOnly + vbCritical, "An Error has Occurred!"
Resume Error_Handler_Exit
End Function