CreateObject("Scripting.FileSystemObject")在Mac的Excel中不起作用 [英] CreateObject("Scripting.FileSystemObject") doesn't work under Excel for Mac
问题描述
我有一段VBA代码,用于获取给定路径的子文件夹,在 Excel for Windows
下可以很好地工作:
I have a piece of VBA code which is used to get subfolders given a path, it works well under Excel for Windows
:
Function GetSubFolders(RootPath As String)
Dim fso As Object
Dim fld As Object
Dim sf As Object
Dim myArr
Set fso = CreateObject("Scripting.FileSystemObject")
Set fld = fso.GetFolder(RootPath)
For Each sf In fld.SUBFOLDERS
Counter = Counter + 1
ReDim Preserve Arr(Counter)
Arr(Counter) = sf.Path
myArr = GetSubFolders(sf.Path)
Next
GetSubFolders = Arr
Set sf = Nothing
Set fld = Nothing
Set fso = Nothing
End Function
现在,我想在 Excel for Mac
(版本:2011 14.4.1)下运行此代码.它在行 Set fso = CreateObject("Scripting.FileSystemObject")
处给出错误.错误消息为运行时错误'429':ActiveX组件无法创建对象
.
Now I would like to run this code under Excel for Mac
(version: 2011 14.4.1). It gives an error at the line Set fso = CreateObject("Scripting.FileSystemObject")
. The error message is Run-time error '429': ActiveX component can't create object
.
有人可以帮我调试吗?
推荐答案
FileSystemObject是Windows脚本库的一部分,在Mac OSX中不存在.
The FileSystemObject is part of the Windows scripting library, which doesn't exist on Mac OSX.
之前曾问过类似的问题:我如何安装/使用"Scripting.FileSystemObject"?在Excel 2010中用于MAC吗?
Similar question asked previously: How can I install/use "Scripting.FileSystemObject" in Excel 2010 for MAC?
这篇关于CreateObject("Scripting.FileSystemObject")在Mac的Excel中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!