I believe the post (and title) was edited because I was posting this:
save the filename before saving the file to the new location. After successful ssaving delete old file.
something like this:
Code:
dim varFile as string
varFile = thisworkbook.path & "\" & thisworkbook.name
.... your code for saving to new location ....
Dim objFS as object
Set objFS = CreateObject("Scripting.FileSystemObject")
objFS.DeleteFile varFile, True
So if I took a workbook, dragged it onto the desktop, saved-as into documents (so now I have a copy on the desktop and a copy in my documents folder), and then I wanted to kill the original file that was on the desktop, how might I go about doing that? Note: Maybe i want to drag the original somewhere else, so I can't specify the desktop...it's gotta be dynamic. Does that make sense?
awesome so just to make sure (and I need to put a copy on my thumb drive before I start experimenting!),
put the code in, by my code for saving-as, the second part of your code will delete the original file, regardless of where it was saved? And presumably I cannot have both files named the same thing...despite being in different locations?
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.