Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default How do I delete a workbook after the vba has run?

Situation: I have written a purchase order expediting system. It goes and
grab data from my mainframe and populates a spreadsheet. After populating the
code sorts and cleans the data. It them looks at each row of data and if it
is a new (different) vendor it will open a template spreadsheet and populate
that vendor's specific lines. It then saves the template as a unique name
associated to that vendor. The template contains VBA that allows me to upload
the data that the vendor supplies back into the mainframe onc they return the
spreadsheet to me.

Problem: After I update my mainframe I need to delete the spreadsheet...
since its job is now done. This is also important because there can be
hundreds of sheets generated by the main program and after I get the vendor
sheets back and uploaded I need to clean them out so I do not duplicate the
work (I cannot keep track of 100s of sheets anymore... could be old age).

Questions: Is there a way to code the deletion of a sheet with VBA code that
exists IN that same sheet? Would I have to capture the sheet name, save it as
something else, then delete the original sheet name? Does anyone have any
suggestions for how I could do it differently?

Sincerely appreciated,
patrick
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default How do I delete a workbook after the vba has run?

You can delete it from within itself because the are deleting the HDD image

Kill Thisworkbook.FullName

but the workbook still exists in memory, so you will need to close it and
make sure it does ask to be saved

ThisWorkbook.Close SaveChanges:=False

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Patrick" wrote in message
...
Situation: I have written a purchase order expediting system. It goes and
grab data from my mainframe and populates a spreadsheet. After populating

the
code sorts and cleans the data. It them looks at each row of data and if

it
is a new (different) vendor it will open a template spreadsheet and

populate
that vendor's specific lines. It then saves the template as a unique name
associated to that vendor. The template contains VBA that allows me to

upload
the data that the vendor supplies back into the mainframe onc they return

the
spreadsheet to me.

Problem: After I update my mainframe I need to delete the spreadsheet...
since its job is now done. This is also important because there can be
hundreds of sheets generated by the main program and after I get the

vendor
sheets back and uploaded I need to clean them out so I do not duplicate

the
work (I cannot keep track of 100s of sheets anymore... could be old age).

Questions: Is there a way to code the deletion of a sheet with VBA code

that
exists IN that same sheet? Would I have to capture the sheet name, save it

as
something else, then delete the original sheet name? Does anyone have any
suggestions for how I could do it differently?

Sincerely appreciated,
patrick



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete duplicates on 2nd workbook Dude Excel Discussion (Misc queries) 4 July 21st 09 11:34 PM
How can I delete all matches in a workbook? LiveUser Excel Worksheet Functions 4 January 18th 08 08:55 PM
How to Delete a Range in Closed Workbook (to Replace Delete Query) [email protected] Excel Discussion (Misc queries) 1 March 8th 06 10:10 AM
how do you delete a workbook Bob Excel Discussion (Misc queries) 2 October 3rd 05 12:18 AM
how do I delete a workbook tubby55 Excel Programming 2 August 28th 04 08:03 AM


All times are GMT +1. The time now is 04:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"