Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
853 views
in Technique[技术] by (71.8m points)

vba - How can I install/use "Scripting.FileSystemObject" in Excel 2010 for MAC?

I am using Excel for Mac 2011 which has VBA version 14.0.

I am trying to use this code which accesses the file system, which I know works on Windows:

Function qfil_GetDirectory(strDirectoryName As String)

    Dim objFSO As Variant
    Dim objDirectory As Variant

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objDirectory = objFSO.GetFolder(strDirectoryName)
    Set qfil_GetDirectory = objDirectory

End Function

However, when I run it in Excel for Mac 2011, it gives me this error:

Run-time error 429 Object creation with ActiveX component not possible

To fix this on Windows, I know I have to just reference a specific DLL under tools.

However on the Mac, when I go under tools | references it only gives me these:

alt text

And none of them allow me to use Scripting.FileSystemObject.

What do I have to do in Excel 2011 for Mac so that I can use Scripting.FileSystemObject to read files from the hard drive from an Excel sheet via VBA?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

To my knowledge, this approach won't be valid on Mac, as the external library doesnt exist.

Don't know Office 11 VBA, but the Dir() function works accross platforms for '03.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...