deleting a file without an address

sassriverrat

Well-known Member
Joined
Oct 4, 2018
Messages
655
anyone know how to get excel an open workbook without specifying an exact address?
 
Last edited:

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Your title does not match your question :confused:

What are you trying to do?
 
Upvote 0
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
 
Upvote 0
sorry.

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?
 
Upvote 0
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?
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

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