Question

I'm having trouble using filesystemobject in a vba function I am writing. I keeping getting the error: Runtime error 424 Object required

I have found lots of stuff online but none of it has done any good. Yes I have checked the References and Microsoft Scripting Runtime is checked. Here is as snippet of code please tell me what I am doing wrong. I have tried changing the first line to Dim objFSO as New FileSystemObject among other things but they are produce the same error. The error occurs on the second line.

Dim objFSO
Set objFSO = CreateObject(”Scripting.FileSystemObject”)
Was it helpful?

Solution

You are using odd quotes, use plain quotes.

Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")

OTHER TIPS

If you add a reference to Microsoft Scripting Runtime, you don't need to use CreateObject; instead you can just call:

Dim objFSO=new FileSystemObject
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top