Solved

As an error with the required object in VBA

Posted on 2011-03-22
2
430 Views
Last Modified: 2012-06-27
Hi,
can you help me with my macro to delete a file? When I start writing on the fifth row of the error: Run-time error '424' - Object required
Thank you in advance.

Regards,
TM
Sub DeleteFile()
Dim fso, sTemp
Dim file As String
sTemp = Environ("TEMP")
file = sTemp & "\" & student_scores.Log
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(file) Then
    fso.DeleteFile file, True
Else
    MsgBox file & " does not exist or has already been deleted!" _
            , vbExclamation, "File not Found"
End If
End Sub

Open in new window

0
Comment
Question by:Thomas_Meyer
2 Comments
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 500 total points
Comment Utility
Change:

   file = sTemp & "\" & student_scores.Log

to:

   file = sTemp & "\student_scores.Log"

Kevin
0
 

Author Closing Comment

by:Thomas_Meyer
Comment Utility
helped, thanks!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now