0

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

2 Answers 2

2

You are using odd quotes, use plain quotes.

Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Sign up to request clarification or add additional context in comments.

1 Comment

Ahh that's what I get for copying and pasting from the internet. I should have been more aware of that. Thank you
-1

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

2 Comments

This doesn't address the problem, and it appears to have been posted hours after the true solution was posted and acknowledged. Also the line of code is not accepted in the VBA editor.
You're right, it should be the line Dim objFSO as FileSystemObject followed by the line Set objFSO = New FileSystemObject. Rookie error from my early days of learning VBA.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.