Kill/Delete file in current path

LNG2013

Active Member
Joined
May 23, 2011
Messages
466
I have a file, test.csv, that is in the same folder as my macro.xls.
How do I delete the test.csv, without using the full path extension. This macro runs on computers with different path setups.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Code:
Kill Thisworkbook.Path & "\test.csv"
 
Upvote 0
I am doing this, it deletes my workbook that I said to kill, my problem is that in the new save path that I have, I am still using that macro to save my files and changes I make but that last line comes up still giving me error 53 that the kill statement is impossible since the template was already deleted. I want to know how can I make the if statement or Error 53 code that just ignores this Kill code if file not found and not give me and error code
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,275
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top