如何在Mac中使用vba删除所有文件和文件夹?

如何在Mac中使用vba删除所有文件和文件夹?,vba,Vba,我知道如何在Windows计算机上做这件事。以下是windows的代码: Sub delete_contents_of_Sallima_folder() Dim FSO As Object Dim MyPath As String Set FSO = CreateObject("scripting.filesystemobject") MyPath = ActiveWorkbook.path & "\Sallima" If Right(MyP

我知道如何在Windows计算机上做这件事。以下是windows的代码:

Sub delete_contents_of_Sallima_folder()
    Dim FSO As Object
    Dim MyPath As String

    Set FSO = CreateObject("scripting.filesystemobject")

    MyPath = ActiveWorkbook.path & "\Sallima"

    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

    On Error Resume Next
    'Delete files
    FSO.deletefile MyPath & "\*.*", True
    'Delete subfolders
    FSO.deletefolder MyPath & "\*.*", True
    On Error GoTo 0

End Sub
但这一行的Mac显示错误:

Set FSO = CreateObject("scripting.filesystemobject")
运行时错误“429 活动X组件无法创建对象“


如何在Mac中执行此任务?请帮助我。

可能重复我想为Mac执行此操作。使用VBA本机的
Dir
Kill
而不是外部参考的FSO。问题是RmDir仅适用于空文件夹。