Be the first user to complete this post

  • 0
Add to List

FileSystemObject : GetFolder Method

Description:

Returns a Folder object corresponding to the folder in a specified path.

Format : 

objectOfFileSystemObject. GetFolder(folderspec)

Arguments: 
  • objectOfFileSystemObject
    • As the names says, it’s a FileSystemObject.
  • folderspec
    • Mandatory
    • Type:     String
    • Specific folder path
Function FnGetFolderList(strSpecificFolderPath)

    Set fso = CreateObject("Scripting.FileSystemObject")

    Set folder = fso.GetFolder(strSpecificFolderPath)

    Set subFolders = folder.SubFolders

    strFolders = ""

    For Each fld in subFlds

        strFolders = strFolders & fld.name

        strFolders = strFolders & " "

    Next

    FnGetFolderList= strFolders

End Function

 Msgbox FnGetFolderList ("c:\New Folder")



Also Read:

  1. FileSystemObject : FileExists Method
  2. VBA-Excel: Add/Insert multiple objects from a folder in an Excel Document.
  3. FileSystemObject : CreateTextFile Method
  4. FileSystemObject : GetExtensionName Method
  5. FileSystemObject : DeleteFile Method
  6. FileSystemObject : DeleteFolder Method
  7. FileSystemObject in Excel Macro
  8. FileSystemObject : CopyFile Method