Macro to copy a file from one location to another location

THRASHER69

Board Regular
Joined
Mar 29, 2012
Messages
200
I am trying to make my workbook copy the saved file from one network location to another network location when I close the file. I have the code below under ThisWorkbook but it does not work. What am I missing?

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)

    FileCopy "M;\msapps\excel\Warehouse Planning\Office 2010 Sheets (Working)\Open Order Report.xlsm", "T:\WareHouse Planning\Open Order Report.xlsm"


End Sub
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
I am trying to make my workbook copy the saved file from one network location to another network location when I close the file. I have the code below under ThisWorkbook but it does not work. What am I missing?

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)

    FileCopy "M:\msapps\excel\Warehouse Planning\Office 2010 Sheets (Working)\Open Order Report.xlsm", "T:\WareHouse Planning\Open Order Report.xlsm"


End Sub

It's fixed here
 
Upvote 0
ADVERTISEMENT
Syntax looks okay to me. Not sure what could be wrong other than something being wrong with the source file path.

Maybe try pasting your source file path directly from code to Windows Explorer "Search Library". If Explorer can't find it you must have a typo in the path

or

Try it this way. If it works it also indicates an invalid path / filename in your previous attempt:

Code:
FileCopy ThisWorkbook.FullName, "T:\WareHouse Planning\Open Order Report.xlsm"
 
Upvote 0
Syntax looks okay to me. Not sure what could be wrong other than something being wrong with the source file path.

Maybe try pasting your source file path directly from code to Windows Explorer "Search Library". If Explorer can't find it you must have a typo in the path

or

Try it this way. If it works it also indicates an invalid path / filename in your previous attempt:

Code:
FileCopy ThisWorkbook.FullName, "T:\WareHouse Planning\Open Order Report.xlsm"

Same error message with this code also. It's run-time error 70: Permission denied
 
Upvote 0
Sorry about that. Next time I will. Thanks for your help but it looks like I'm screwed with the permissions thing
 
Upvote 0

Forum statistics

Threads
1,196,487
Messages
6,015,493
Members
441,898
Latest member
kofafa

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