Copy workbook to another location without opening

leeloo0505

Board Regular
Joined
Mar 28, 2003
Messages
130
Hello,
I am trying to copy a workbook without opening it and save it to a different location/file name (2nd workbook) from a third workbook.
Anybody got any ideas?
Thanks,
leeloo
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> CopyFile()

FileCopy Source:="C:\Book3.xls", Destination:="C:\VBA Code\Book5.xls"

<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
</FONT>
 
Upvote 0
How could this be adjusted to write over the destination file each time but as the same file name.. Thanks
 
Upvote 0
Try like this

Code:
Sub CopyFile()
On Error Resume Next
Kill "C:\VBA Code\Book5.xls"
On Error GoTo 0
FileCopy Source:="C:\Book3.xls", Destination:="C:\VBA Code\Book5.xls"
End Sub
 
Upvote 0
Peter if another user has open book5 when the code is executed will it still replace it even though its open.
 
Upvote 0
If i want to use the Active Workbook could this work ?
On Error Resume Next
Kill "H:\All\Material Prep Archive\(Public)Archive .xls"
On Error GoTo 0
FileCopy Source:="Activeworkbook:="H:\All\Material Prep Archive\(Public)Archive .xls"
 
Upvote 0
If i want to use the Active Workbook could this work ?

I think that you would need

Code:
On Error Resume Next
Kill "H:\All\Material Prep Archive\(Public)Archive .xls"
On Error GoTo 0
FileCopy Source:=ActiveWorkbook.FullName, Destination:="H:\All\Material Prep Archive\(Public)Archive .xls"
 
Upvote 0
If i add the On Error Resume Next above the file copy will it skip the FileCopy if the destination (PublicArchive.xls) is open?
Like Below

On Error Resume Next
Kill "H:\All\Material Prep Archive\(Public)Archive .xls"
On Error GoTo 0
On Error Resume Next
FileCopy Source:=ActiveWorkbook.FullName, Destination:="H:\All\Material Prep Archive\(Public)Archive .xls"
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,756
Members
452,940
Latest member
rootytrip

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