Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
macro for copy-pasting from different workbooks | Excel Worksheet Functions | |||
Macro - save to current location vs excel default location | Excel Discussion (Misc queries) | |||
Using Macro to Save Copy of File to New Location | Excel Discussion (Misc queries) | |||
Copy non-Zero columns to new location macro | Excel Programming | |||
Macro to copy and paste between two workbooks | Excel Programming |