FileSystemObject not defined

G

Guest

Want to delete a text file after importing its data into Access. Tried this,
got following message. Tried to add in References but couldn't find.
Suggestions???

Dim Fso As New FileSystemObject
Set Fso = CreateObject("Scripting.FileSystemObject")
Fso.DeleteFile ("C:\Documents and Settings\Ray\Desktop\TestExtract.txt")

error: User-Defined Type Not Defined
 
R

Rick Brandt

Ray said:
Want to delete a text file after importing its data into Access.
Tried this, got following message. Tried to add in References but
couldn't find. Suggestions???

Dim Fso As New FileSystemObject
Set Fso = CreateObject("Scripting.FileSystemObject")
Fso.DeleteFile ("C:\Documents and
Settings\Ray\Desktop\TestExtract.txt")

error: User-Defined Type Not Defined

No need for an external call to Fso. Just use...

Kill "C:\Documents and Settings\Ray\Desktop\TestExtract.txt"
 
D

Douglas J Steele

Actually, if you haven't got a reference set to the Scripting library, you'd
be better off using:

Dim Fso As Object

However, as Rick pointed out, there's no reason to instantiate the overhead
of FSO strictly to delete a file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top