Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have many level 1 subfolders with examples shown below
Country America Germany Japan France In each subfolders are some excel files. I want to paste some values from a master file to all the excel files found in the subfolders. Anyone can help? Thanks. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi linglc
You can adapt this macro http://www.rondebruin.nl/fso.htm If you need help post back -- Regards Ron de Bruin http://www.rondebruin.nl "linglc" wrote in message ... I have many level 1 subfolders with examples shown below Country America Germany Japan France In each subfolders are some excel files. I want to paste some values from a master file to all the excel files found in the subfolders. Anyone can help? Thanks. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Sub LoopFolders() Set oFSO = CreateObject("Scripting.FileSystemObject") selectFiles "c:\MyTest" Set oFSO = Nothing End Sub '--------------------------------------------------------------------------- Sub selectFiles(sPath) '--------------------------------------------------------------------------- Dim Folder As Object Dim Files As Object Dim file As Object Dim fldr Set Folder = oFSO.GetFolder(sPath) For Each fldr In Folder.Subfolders selectFiles fldr.Path Next fldr For Each file In Folder.Files If file.Type = "Microsoft Excel Worksheet" Then Workbooks.Open Filename:=file.Path End If Next file End Sub -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "linglc" wrote in message ... I have many level 1 subfolders with examples shown below Country America Germany Japan France In each subfolders are some excel files. I want to paste some values from a master file to all the excel files found in the subfolders. Anyone can help? Thanks. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Bob,
Thanks for your reply. However I have some problem with this row Set Folder = oFSO.GetFolder(sPath) I get the message -- run time error '424' : object required Do you know why? -- help needed "Bob Phillips" wrote: Sub LoopFolders() Set oFSO = CreateObject("Scripting.FileSystemObject") selectFiles "c:\MyTest" Set oFSO = Nothing End Sub '--------------------------------------------------------------------------- Sub selectFiles(sPath) '--------------------------------------------------------------------------- Dim Folder As Object Dim Files As Object Dim file As Object Dim fldr Set Folder = oFSO.GetFolder(sPath) For Each fldr In Folder.Subfolders selectFiles fldr.Path Next fldr For Each file In Folder.Files If file.Type = "Microsoft Excel Worksheet" Then Workbooks.Open Filename:=file.Path End If Next file End Sub -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "linglc" wrote in message ... I have many level 1 subfolders with examples shown below Country America Germany Japan France In each subfolders are some excel files. I want to paste some values from a master file to all the excel files found in the subfolders. Anyone can help? Thanks. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sorry, I missed one vital line.
AT the very start, before the first sub, add Dim oFSO As Object -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "linglc" wrote in message ... Bob, Thanks for your reply. However I have some problem with this row Set Folder = oFSO.GetFolder(sPath) I get the message -- run time error '424' : object required Do you know why? -- help needed "Bob Phillips" wrote: Sub LoopFolders() Set oFSO = CreateObject("Scripting.FileSystemObject") selectFiles "c:\MyTest" Set oFSO = Nothing End Sub '--------------------------------------------------------------------------- Sub selectFiles(sPath) '--------------------------------------------------------------------------- Dim Folder As Object Dim Files As Object Dim file As Object Dim fldr Set Folder = oFSO.GetFolder(sPath) For Each fldr In Folder.Subfolders selectFiles fldr.Path Next fldr For Each file In Folder.Files If file.Type = "Microsoft Excel Worksheet" Then Workbooks.Open Filename:=file.Path End If Next file End Sub -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "linglc" wrote in message ... I have many level 1 subfolders with examples shown below Country America Germany Japan France In each subfolders are some excel files. I want to paste some values from a master file to all the excel files found in the subfolders. Anyone can help? Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Opening files in folders and subfolders | Excel Discussion (Misc queries) | |||
Map/List of folders, subfolders & files | Excel Programming | |||
replace text in files within subfolders | Excel Programming | |||
copy subfolders, replace text in files and save files in copied subfolders | Excel Programming | |||
Modify - look at files within subfolders | Excel Programming |