Delete a .csv file using word macro

T

tarantula

hello,

i have a .csv file created through a word macro that serves as a
intermediate file in my project. But i want to delete it after i hav
used it in my code. I used the following code:

Dim KillFile As String
KillFile = "c:\Document And Settings\User\Desktop\Reviewer.csv"
'Check that file exists
If Len(Dir$(KillFile)) > 0 Then
'First remove readonly attribute, if set
SetAttr KillFile, vbNormal
'Then delete the file
Kill KillFile


But the above code doesnt work and gives error message.

Thank you in advance.

Seeking Help!!
Tarantula
 
S

Simon Lloyd

Where does the code fault?, whats the error
tarantula;415488 said:
hello

i have a .csv file created through a word macro that serves as a
intermediate file in my project. But i want to delete it after i hav
used it in my code. I used the following code

Dim KillFile As Strin
KillFile = "c:\Document And Settings\User\Desktop\Reviewer.csv
'Check that file exist
If Len(Dir$(KillFile)) > 0 The
'First remove readonly attribute, if se
SetAttr KillFile, vbNorma
'Then delete the fil
Kill KillFil


But the above code doesnt work and gives error message

Thank you in advance

Seeking Help!
Tarantula

--
Simon Lloy

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com
 
S

Simon Lloyd

tarantula, that error is because the file is either password protecte
or in a folder you do not have permissions in, the code you supplie
(although your missing End If) is the correct way to delete a file
The error message displays
Run-Time Error-7
'Permission Denied' tarantula;415488 Wrote:
hello

i have a .csv file created through a word macro that serves as a
intermediate file in my project. But i want to delete it after i hav
used it in my code. I used the following code
Code
-------------------
Dim KillFile As Strin
KillFile = "c:\Document And Settings\User\Desktop\Reviewer.csv
'Check that file exist
If Len(Dir$(KillFile)) > 0 The
'First remove readonly attribute, if se
SetAttr KillFile, vbNorma
'Then delete the fil
Kill KillFil

-------------------
But the above code doesnt work and gives error message

Thank you in advance

Seeking Help!
Tarantula

--
Simon Lloy

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com
 

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