[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Create Directories from List

Posted on 2004-04-27
5
Medium Priority
?
336 Views
Last Modified: 2010-08-05
I am trying to create directories from a list in excel

In vba I need the syntax to check if a directory exists & also the syntax to create a directory

Looking forward
0
Comment
Question by:smaill
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
wolfking earned 1000 total points
ID: 10928565
Dir Function Example
This example uses the Dir function to check if certain files and directories exist. On the Macintosh, “HD:” is the default drive name and portions of the pathname are separated by colons instead of backslashes. Also, the Microsoft Windows wildcard characters are treated as valid file-name characters on the Mac. However, you can use the MacID function to specify file groups.

Dim MyFile, MyPath, MyName
' Returns "WIN.INI" (on Microsoft Windows) if it exists.
MyFile = Dir("C:\WINDOWS\WIN.INI")    

' Returns filename with specified extension. If more than one *.ini
' file exists, the first file found is returned.
MyFile = Dir("C:\WINDOWS\*.INI")

' Call Dir again without arguments to return the next *.INI file in the
' same directory.
MyFile = Dir

' Return first *.TXT file with a set hidden attribute.
MyFile = Dir("*.TXT", vbHidden)

' Display the names in C:\ that represent directories.
MyPath = "c:\"    ' Set the path.
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
            Debug.Print MyName    ' Display entry only if it
        End If    ' it represents a directory.
    End If
    MyName = Dir    ' Get next entry.
Loop




MkDir path

The required path argument is a string expression that identifies the directory or folder to be created. The path may include the drive. If no drive is specified, MkDir creates the new directory or folder on the current drive.
0
 
LVL 1

Expert Comment

by:wolfking
ID: 10928591
MkDir Statement Example
This example uses the MkDir statement to create a directory or folder. If the drive is not specified, the new directory or folder is created on the current drive.

MkDir "MYDIR"    ' Make new directory or folder.

0
 
LVL 4

Assisted Solution

by:JpmSoft
JpmSoft earned 1000 total points
ID: 10930853
1.- Open the VBA editor and add a reference to Microsoft Scripting Runtime
2.- Declare a FileSystemObject object:
        Dim FSO As New FileSystemObject
3.- For I=0 To LastRowOfList
   If Not FSO.FolderExist(oSheet.Cells(I,1)) Then
       FSO.CreateFolder oSheet.Cells(I,1)
   End If
Next I
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Group policies can be applied selectively to specific devices with the help of groups. Utilising this, it is possible to phase-in group policies, over a period of time, by randomly adding non-members user or computers at a set interval, to a group f…
A bad practice commonly found during an account life cycle is to set its password to an initial, insecure password. The Password Reset Tool was developed to make the password reset process easier and more secure.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question