![]() |
Macro to copy workbooks from one location to another.
I have a folder that contains about 100 workbooks and these workbooks have to
always be there. What I do now is go to that folder copy all the workbooks and then past them into a folder on my desktop. Is there a macro or batch file or something that I can creat that all I have to do is hit "run" or something and have it go out, copy everythign in that folder and past it to the folder on my desktop? Thanks; The Dawg |
Macro to copy workbooks from one location to another.
Try this: Sub copy_contents_of_folder() sourcepathname = "C:\MyFolder\" destpathname = "C:\WINNT\Profiles\MyUserName\Desktop\MyOtherFolde r\" filemask = "*.xls" fname = Dir(sourcepathname & filemask, vbNormal) Do While fname < "" FileCopy sourcepathname & fname, destpathname & fname fname = Dir() Loop End Sub Change the values of "sourcepathname" and "destpathname" to the relevant folders - don't forget the trailing \'s Hope it helps Col -- colofnature ------------------------------------------------------------------------ colofnature's Profile: http://www.excelforum.com/member.php...o&userid=34356 View this thread: http://www.excelforum.com/showthread...hreadid=543080 |
Macro to copy workbooks from one location to another.
I'm having trouble getting this to work. Here is my code. I'm not getting any
error: Sub copy_contents_of_folder() sourcepathname = "C:\Documents and Settings\dmobley\Desktop\JunkFolder\TESTEXCEL" destpathname = "C:\Documents and Settings\dmobley\My Documents\My Music" filemask = "*.xls" fname = Dir(sourcepathname & filemask, vbNormal) Do While fname < "" FileCopy sourcepathname & fname, destpathname & fname fname = Dir() Loop End Sub "colofnature" wrote: Try this: Sub copy_contents_of_folder() sourcepathname = "C:\MyFolder\" destpathname = "C:\WINNT\Profiles\MyUserName\Desktop\MyOtherFolde r\" filemask = "*.xls" fname = Dir(sourcepathname & filemask, vbNormal) Do While fname < "" FileCopy sourcepathname & fname, destpathname & fname fname = Dir() Loop End Sub Change the values of "sourcepathname" and "destpathname" to the relevant folders - don't forget the trailing \'s Hope it helps Col -- colofnature ------------------------------------------------------------------------ colofnature's Profile: http://www.excelforum.com/member.php...o&userid=34356 View this thread: http://www.excelforum.com/showthread...hreadid=543080 |
Macro to copy workbooks from one location to another.
Couple of things - first, add "\" to the end of values in "sourcepathname" and "destpathname", and second, if you're copying anything other than spreadsheets you'll need to change the value of "filemask" to whatever the extension is for that type of file (e.g. "*.mp3", "*.jpg" etc) Col -- colofnature ------------------------------------------------------------------------ colofnature's Profile: http://www.excelforum.com/member.php...o&userid=34356 View this thread: http://www.excelforum.com/showthread...hreadid=543080 |
Macro to copy workbooks from one location to another.
Couple of things - first, add "\" to the end of values i "sourcepathname" and "destpathname", and second, if you're copyin anything other than spreadsheets you'll need to change the value o "filemask" to whatever the extension is for that type of file (e.g "*.mp3", "*.jpg" etc) Co -- colofnatur ----------------------------------------------------------------------- colofnature's Profile: http://www.excelforum.com/member.php...fo&userid=3435 View this thread: http://www.excelforum.com/showthread.php?threadid=54308 |
All times are GMT +1. The time now is 01:09 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com