Results 1 to 2 of 2

Thread: Multiple Select with CommonDialog

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    NY, USA.
    Posts
    240

    Post

    Does Anyone know how to use the CommonDialog
    control to select multiple files and then add there names to a listbox?

    ------------------
    OmarSwan
    [email protected]
    http://www.omarswan.cjb.net
    To God Be The Glory

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845

    Post

    The fisrt iitem in the list will contain the path so you can either remove it or use it to create a full path for the other list items


    Code:
    Private Sub cmdOpen_Click()
    
          Dim Counter As Long
          Dim FileNames As String
          Dim Length As Long
          Dim Start As Long
    
          
          CommonDialog1.Filter = "All Files|*.*"
          CommonDialog1.FilterIndex = 0
          CommonDialog1.Flags = MSComDlg.cdlOFNExplorer Or MSComDlg.cdlOFNAllowMultiselect Or MSComDlg.cdlOFNFileMustExist Or MSComDlg.cdlOFNHideReadOnly Or MSComDlg.cdlOFNPathMustExist
    
          CommonDialog1.ShowOpen
          FileNames = CommonDialog1.filename
          If FileNames = "" Then
            Exit Sub
          End If
        
        ' Unpack the file names
          Length = VBA.Len(FileNames)
          Counter = 1
          Start = 1
          While Counter < Length
            While Mid(FileNames, Counter, 1) <> Chr(0) And Counter < Length
              Counter = Counter + 1
            Wend
    
            
            List1.AddItem Trim(Mid(FileNames, Start, Counter - Start))
            
            Counter = Counter + 1
            Start = Counter
          Wend
          
    End Sub
    ------------------
    Mark Sreeves
    Analyst Programmer

    [email protected]
    A BMW Group Company



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width