Ken
Ken

Reputation: 87

trouble with using filesystemobject in vba

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”)

Upvotes: 0

Views: 3971

Answers (2)

sigil
sigil

Reputation: 9546

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

Upvotes: -1

Fionnuala
Fionnuala

Reputation: 91336

You are using odd quotes, use plain quotes.

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

Upvotes: 2

Related Questions