title: Check if the folder is empty
body: <p>My code should loop through Folders/Subs and determine if there is any file there.</p>
  
  <p>I have 2 questions:</p>
  
  <ol>
  <li><p>I am not getting any feedback if there are NO Folders/Subs in certain Folders. A specific case: If it detects files (not Folders), assume there are some files (Excel for instance) in it the program says "Empty Folder"?</p></li>
  <li><p>On the Open Window dialog to select a Folder, if I click Cancel it gives me a Popup window stating: "Folder not empty..blabla..." </p></li>
  </ol>
  
  <pre class="lang-vb prettyprint-override"><code>Sub Button1_click()
  
  Dim FileSystem As Object
  Dim HostFolder As String
  Dim Answer As String
  Dim fs, strFolderPath, oFolder
  
  ' *** Folder with Files to perform an action ***
  HostFolder = GetSourceFolder()
  
  Application.ScreenUpdating = False
  Application.Calculation = xlCalculationManual
  
  ' *** This is your folder to define ***
      Set fs = CreateObject("Scripting.FileSystemObject")
      strFolderPath = Application.ActiveWorkbook.Path
      Set oFolder = fs.getfolder(strFolderPath)
          If (oFolder.SubFolders.Count = 0) Then
  
  ' *** If folder is empty/full message ***
  ' * Folder is Empty *
         MsgBox "Folder is empty!", vbOKOnly + vbInformation, "Information!"
  
          Else
  ' * Folder isn't empty *
         Answer = MsgBox("Folder not empty! Proceed with Macro?", vbYesNo + vbInformation + vbDefaultButton1, "Information!")
          If Answer = vbNo Then Exit Sub
      End If
  
  Set fs = Nothing
  
  Set FileSystem = CreateObject("Scripting.FileSystemObject")
      Dim targetFolder As String
      targetFolder = GetTargetFolder()
  
      DoFolder FileSystem.getfolder(HostFolder)
  
      Application.ScreenUpdating = True
      Application.Calculation = xlCalculationAutomatic
  
  End Sub
  
  
  Function GetSourceFolder() As String
      Dim fldr As FileDialog
      Dim sItem As String
      Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
      With fldr
          .Title = "Select Source Folder"
          .AllowMultiSelect = False
          .InitialFileName = Application.DefaultFilePath
          If .Show &lt;&gt; -1 Then GoTo NextCode
          sItem = .SelectedItems(1)
      End With
  NextCode:
      GetSourceFolder = sItem
      Set fldr = Nothing
  End Function
  
  Function GetTargetFolder() As String
      Dim fldr As FileDialog
      Dim sItem As String
      Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
      With fldr
          .Title = "Select Output Folder"
          .AllowMultiSelect = False
          .InitialFileName = Application.DefaultFilePath
          If .Show &lt;&gt; -1 Then GoTo NextCode
          sItem = .SelectedItems(1)
      End With
  NextCode:
      GetTargetFolder = sItem
      Set fldr = Nothing
  End Function
  </code></pre>