View Full Version : Deleting a File


aziz rasul
09-16-2008, 07:17 AM
I have the following VBA code in a module, which deletes a file: -

Public Sub KillFile(strFilepath As String, strFilename As String)

If Dir(strFilepath & strFilename) <> "" Then
Kill (strFilepath & strFilename)
End If

End Sub

I have a file called "L:\Files\Information\Reports\Inpatients\Theatre Session Utilisation and Activity.xls"

The L drive is mapped to the network, which is called

xdeptSH on 'EMC-SNAS:T5.5.32.4 (stg1nas01)' (L: )

I want to delete the Theatre Session Utilisation and Activity.xls file without referring to the L drive as other people will be using the db and they may be mapped to the network using a different letter.

How do I call the KillFile code using the network path?

KenHigg
09-16-2008, 07:24 AM
It should look something like:

\\stg1nas01\xdeptSH\Files\Information\Reports\Inpa tients\Theat re Session Utilisation and Activity.xls

aziz rasul
09-16-2008, 07:26 AM
I've tried that and I get error 52, 'bad file name or number'.

aziz rasul
09-16-2008, 07:36 AM
Sorry, I placed the filepath incorrectly. It works now. Thanks.

KenHigg
09-16-2008, 08:10 AM
Cool - Glad you have it working.