Multiple Files with CommonDialog

By | 2019-08-24

Ever wonder how to return multiple files using the CommonDialog control? Here is a short demonstration of how to get it done.

Private Sub cmdOpen_Click()
   Dim sFileNames() As String
   Dim iCount As Integer

   cd.Filter = "All Files|*.*"
   cd.Flags = cdlOFNAllowMultiselect
   cd.ShowOpen

   If cd.FileName <> "" Then
      sFileNames = Split(cd.FileName, Chr(32))
      For iCount = LBound(sFileNames) To UBound(sFileNames)
         MsgBox sFileNames(iCount), vbInformation
      Next

   End If
End Sub

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.