VBscript – Create Folders from Excel


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'========================================================
'
' NAME: FolderFromExcel.vbs
'
' COMMENT:  Script will read Excel file.  Column A should contain
'                  folder names. Folders will then be created.
'
'========================================================
Dim objExcel, strPathExcel,strCN
Dim objFile, intRow

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objExcel = CreateObject("Excel.Application")
strPathExcel = "c:\temp\excel.xls"
objExcel.Workbooks.open strPathExcel
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)

intRow = 1

Do Until objExcel.Cells(intRow, 1).Value = ""
    strCN = Trim(objSheet.Cells(intRow, 1).Value)
    If objFSO.FolderExists("c:\temp\" & strCN) Then
    Else
        objFSO.CreateFolder("c:\temp\" & strCN)
    End If
    intRow = intRow + 1
Loop

objExcel.Quit

MsgBox "Done",,"Completed"



You can leave a response, or trackback from your own site.


Further Reading
    None Found




Leave a Reply

Anti-Spam Quiz:

Twitter Delicious Facebook Digg Stumbleupon Favorites More
334 queries in 2.865 seconds.