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

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
<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,214,814
Messages
6,121,711
Members
449,049
Latest member
THMarana

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