Link to home
Start Free TrialLog in
Avatar of Pierre K
Pierre KFlag for South Africa

asked on

Delete file from Server

Hi all,
I'm using WPut and WGet to upload and download files to a FTP Server but need some Access VBA code to delete a file from there please.
Maybe some FTP Shell command?

Avatar of Kanti Prasad
Kanti Prasad


You can use
delete  filename.ext
mdelete *.ext
Avatar of Pierre K


@Kanti - thanks for the reply.
Could you provide more info as to how I would implement this in Access VBA please?
As explained the file I need to delete resides on my Web Server.
So I need some FTP command to delete the specific file

The one I gave you is to run it as a FTP command. Try it and if it works just put it as a .bat file and run it.
@Kanti - I created a bat file with ref to the http path to the file but I'm getting an error stating that the 'delete' or 'mdelete' command doesn't exist

Initially run just with the delete  on that server then we can look giving the path name.

FTP> prompt
FTP> delete filename*.ext  |yes
@Kanti - OK I understand but I need the full code to login and do the delete from within VBA code.
I have an idea how to do it via Command Prompt but not sure how to do it all the way with VBA code.
Sorry - hope that make sense?

Just record a macro in xls and copy this

Sub macro()
Kill "C:\yourdirectorypath\*.ext"
End Sub
Avatar of Gustav Brock
There is no WDel for Windows, but you can run a script for the FTP utility:

@echo off
>file.txt echo open
>>file.txt echo username
>>file.txt echo password
>>file.txt echo cd  /directory
>>file.txt echo binary
>>file.txt echo del %1
>>file.txt echo disconnect
>>file.txt echo bye

ftp -i -s:"file.txt"
del "file.txt"

Open in new window

@Gustav - Ahhh - that sounds far more like the code I need.
I would only be able to test it in the morning (our time).
Only need to figure out how to put it in a Function or VBA script - would be nice if you could help with that...
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@Gustav - Thanks a lot - worked like a dream!
You are welcome!