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

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Forum statistics

Threads
1,223,893
Messages
6,175,249
Members
452,623
Latest member
Techenthusiast

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