|
|
#1 |
|
New Member
Join Date: Apr 07
Posts: 9
![]() |
[2003] Excel+VBA: Save old doc to new location/delete previous doc
Here's my current issue, hopefully someone has some advice on this solution:
Basically, I have an excel doc saved somewhere on a networked drive. What I want, is if someone goes to that excel doc, clicks a button, it would save that excel doc to another location (i can do this already), and delete the old excel doc from the previous location. I'm not sure how I would go about automating the delete process of the old excel doc. I can run a batch file, but a couple of problems arise there; 1) What if there are more than one excel docs in the folder. The batch file needs to know which one to delete. 2) How can an excel doc run a batch file if its already closed. Not sure if there are answers to these other than it can't be done. Any help would be appreciated. Thanks. |
|
|
|
|
|
#2 |
|
New Member
Join Date: Apr 07
Posts: 9
![]() |
Re: [2003] Excel+VBA: Save old doc to new location/delete previous doc
resolved
|
|
|
|
|
|
#3 |
|
PowerPoster
Join Date: Dec 04
Posts: 13,424
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: [2003] Excel+VBA: Save old doc to new location/delete previous doc
there are several ways this could be achieved
one that springs to mind is to put the filename (with path) into an empty cell prior to doing saveas vb Code:
vb Code:
note this could cause problem if later you wanted to store a filename in the selected cell, also the code will run everytime the selection changes you could put the delete code into the workbook open event, but it will not run until the next time the file is opened, but that may not matter, there will be other ways to do the same thing
__________________
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part come back and mark your original post as resolved if your problem is fixed pete |
|
|
|
|
|
#4 |
|
New Member
Join Date: Apr 07
Posts: 9
![]() |
Re: [2003] Excel+VBA: Save old doc to new location/delete previous doc
I already resolved this, here's how I chose to do it:
1) User clicks button 2) Current xls doc is saved to a different location 3) A pop-up comes up indicating to close the current workbook. 4) Upon confirming the pop-up, a batch file is ran on a 30 second timer. 5) After 30 seconds, the old xls document is deleted automatically from the batch file. 6) Issue resolved
|
|
|
|
|
|
#5 |
|
PowerPoster
Join Date: Dec 04
Posts: 13,424
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: [2003] Excel+VBA: Save old doc to new location/delete previous doc
when you saveas the original document closes without saving changes, the new (savedas) document is the one currently open, so there should be no need to close the document to delete the original
__________________
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part come back and mark your original post as resolved if your problem is fixed pete |
|
|
|
![]() |
|
||||||
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|