Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default 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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
macro for copy-pasting from different workbooks Binty Excel Worksheet Functions 1 November 25th 08 03:29 PM
Macro - save to current location vs excel default location leezard Excel Discussion (Misc queries) 0 October 28th 08 03:04 PM
Using Macro to Save Copy of File to New Location Chris Z Excel Discussion (Misc queries) 3 September 12th 06 11:26 PM
Copy non-Zero columns to new location macro Craigm Excel Programming 6 June 16th 05 07:37 PM
Macro to copy and paste between two workbooks Paula Excel Programming 1 May 4th 05 10:11 PM


All times are GMT +1. The time now is 05:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"