PDA

View Full Version : Solved: excel delete a workbook



fourstar787
08-13-2010, 10:39 AM
I have a workbook i send to other depts for them to fill in their section (worksheet) and then click a command button to send the worksheet (in the form of a new workbook) via email back to me.
I have saved the workbook on their pc's C drive so i can give it the req'd name before its emailed back (makes life simple when i receive it as the file name is already in a format i require)

what i wish to know is their VBA code i can use to delete the newly created file from their C drive after its sent (to avoid filling up their drive with files - without their knowledge)

I have only recently started using VBA but have learnt loads so far - but i have yet to find a good reference guide of all the available commands and their usage formats - hence why i have had to resort to asking here!

essentially - what is the vba code to delete a excel workbook ( name and location path are known!)

fourstar787
08-13-2010, 11:16 AM
Or - Am i barking up the wrong tree? is there a way to alter the filename of a open workbook without saving it?

fourstar787
08-13-2010, 12:29 PM
another thought - can i possibly create a new workbook with a specific name?
that way i can create it - mail it, close it without saving it!

gcomyn
08-13-2010, 01:36 PM
the 'kill' command will delete a file.

GComyn
:sleuth:

fourstar787
08-13-2010, 01:44 PM
thanks for the reply !

could you possibly show me an example of how the command is written?
activeworkbook.kill ?
please: pray2:

kill(pathname) - YESSSSSSSSSS!
thank very very much

gcomyn
08-13-2010, 01:53 PM
kill pathname & filename

did you do any help lookup on it?
GComyn
:sleuth:

fourstar787
08-13-2010, 02:00 PM
not on kill command no, didnt know it existed
i did loads of googling on my predicament tho -
all my vba knowledge has so far come from trial and error - i inherited a workbook with my job - trying to improve it has lead me to learn loads
many many thanks for you help.

i ordered some vba books online but they aint arrived yet :(
but i really am shocked at what stuff you can actually do with it.
so far i have cut down a 3 day job down to 7 button clicks and 2 hours of printing :)

I love VBA - just need to learn more!

gcomyn
08-13-2010, 03:09 PM
I know what you mean... I've been in my job for 12 years, and when I first started I had to do about 14 hours of overtime each week to keep up... now, I do about 20 hours of work in a 40 hour week.

I mainly use Access, but I use Excel enough that I learned the intricacies of both.

GComyn
:sleuth:

fourstar787
08-13-2010, 03:18 PM
as i said - i am just starting the learning process! i inherited this workbook - its good but thing dont work as i think they should - i have been altering things for 3 weeks -- made some small but effective improvements - learned loads already.

its just figuring out how a lot of the commands are used!
i was totally shocked at what can be done with vba
I love it - i am totally addicted now - i spend time looking at code lol.
again thanks for your help!

no doubt i will have more questions over time! so hope tto speak to you soon!