ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   please help me with folder and subfolders (https://www.excelbanter.com/excel-programming/344729-please-help-me-folder-subfolders.html)

pieros

please help me with folder and subfolders
 
Can anyone help me with the following;
I've got an original folder with several original subfolders. With VBA
I want to create a testfolder with the same name as the original folder
but in another location. Then I want to create testsubfolders in the
new testfolder with the same names as the original subfolders.
Greetings.


Bob Phillips[_6_]

please help me with folder and subfolders
 
Here is some code

'-----------------------------------------------------------------------
Sub NewFolders()
'-----------------------------------------------------------------------
Dim FSO As Object
Dim oSubFolder As Object
Dim oFolder As Object

Set FSO = CreateObject("Scripting.FileSystemObject")

Set oFolder = FSO.GetFolder("C:\MyTest")
MkDir "C:\Backups"
MkDir "C:\Backups\" & oFolder.shortname
For Each oSubFolder In oFolder.Subfolders
MkDir "C:\Backups\" & oFolder.shortname & "\" & oSubFolder.Name
Next

End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)


"pieros" wrote in message
oups.com...
Can anyone help me with the following;
I've got an original folder with several original subfolders. With VBA
I want to create a testfolder with the same name as the original folder
but in another location. Then I want to create testsubfolders in the
new testfolder with the same names as the original subfolders.
Greetings.




pieros

please help me with folder and subfolders
 
Bob thank you very much!! With some modifications it works very well!!
Thank's again.

Greetings,
Pieros.



All times are GMT +1. The time now is 03:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com