help with vba - Copy file from source to new destination

p4nny

Board Regular
Joined
Jan 13, 2015
Messages
246
Hi,

The following vba works fine, however if a file is locked and is read only, the code stops.

Is there a line I can enter so it ignores the error? Better still, inform which file is read-only?

Code:
sub copyfile()

Kill "\\retail\dfsroot$\31705 - Business Change\3. Business Readiness & Transitioning\Change Impacts\BIM Docs\Database use only\02-01 Logistics-July2017.xlsm"
On Error GoTo 0


FileCopy Source:="\\retail\dfsroot$\31705 - Business Change\3. Business Readiness & Transitioning\Change Impacts\BIM Docs\02-01 Logistics\02-01 Logistics.xlsm", Destination:="\\retail\dfsroot$\31705 - Business Change\3. Business Readiness & Transitioning\Change Impacts\BIM Docs\Database use only\02-01 Logistics-July2017.xlsm"


'logistics




Kill "\\retail\dfsroot$\31705 - Business Change\3. Business Readiness & Transitioning\Change Impacts\BIM Docs\Database use only\03-01 Fulfilment-July2017.xlsm"
On Error GoTo 0


FileCopy Source:="\\retail\dfsroot$\31705 - Business Change\3. Business Readiness & Transitioning\Change Impacts\BIM Docs\03-01 Fulfilment\03-01 Fulfilment.xlsm", Destination:="\\retail\31705 - Business Change\3. Business Readiness & Transitioning\Change Impacts\BIM Docs\Database use only\03-01 Fulfilment-July2017.xlsm"


'fulfilment




End sub
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

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