Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi. I have a folder called Data, with several subfolders inside it. The
number of subfolders and the name of each subfolder will vary over time. I need to copy a template file (on a KNOWN folder) into each subfolder under data. Can this be automated with VBA? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Plagerized from Excel VBA Help: Code ------------------- Sub Test() Dim MyName As String Dim MyPath As String MyPath = "C:\Data\" MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry. Do While MyName < "" ' Start the loop. ' Ignore the current directory and the encompassing directory. If MyName < "." And MyName < ".." Then ' Use bitwise comparison to make sure MyName is a directory. If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then FileCopy "C:\Data\YourFile.ext", "C:\Data\" & MyName & "\YourFile.ext" End If ' it represents a directory. End If MyName = Dir ' Get next entry. Loop End Su ------------------- I've not used the FileCopy method, but it looks to work. You may wan to change it to read Debug.Print "C:\Data\YourFile.ext", "C:\Data\" MyName & "\YourFile.ext" to start with to see where things are copied. -- kkkni ----------------------------------------------------------------------- kkknie's Profile: http://www.excelforum.com/member.php...nfo&userid=754 View this thread: http://www.excelforum.com/showthread.php?threadid=26523 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Look at the Excel VBA example for the Dir command. This can help you
identify the folders in a directory. -- Regards, Tom Ogilvy "Steph" wrote in message ... Hi. I have a folder called Data, with several subfolders inside it. The number of subfolders and the name of each subfolder will vary over time. I need to copy a template file (on a KNOWN folder) into each subfolder under data. Can this be automated with VBA? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks guys!
"Tom Ogilvy" wrote in message ... Look at the Excel VBA example for the Dir command. This can help you identify the folders in a directory. -- Regards, Tom Ogilvy "Steph" wrote in message ... Hi. I have a folder called Data, with several subfolders inside it. The number of subfolders and the name of each subfolder will vary over time. I need to copy a template file (on a KNOWN folder) into each subfolder under data. Can this be automated with VBA? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
copy and pasting one file into several different folders | Excel Discussion (Misc queries) | |||
copy workbook into multiple folders | Excel Discussion (Misc queries) | |||
how to open a file with a same name but in different folders | Excel Discussion (Misc queries) | |||
opening multiple .txt files from multiple folders | Excel Discussion (Misc queries) | |||
Help on file and folders Please | Excel Programming |