Results 1 to 4 of 4

Thread: Multiple Select

  1. #1

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Multiple Select

    I want to select multiple files from Common Dialog ...
    How to do it ...?

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Multiple Select

    Set the .Flags property to cdlOFNAllowMultiselect and thats it.
    Its also good to Or these other flags to it too.

    cdlOFNFileMustExist
    cdlOFNPathMustExist
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Re: Multiple Select

    hi Rob..
    now i also want to retrieve filenames separately as well..

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Multiple Select

    As Rob said, the cdlOFNAllowMultiselect flag will allow you to select multiple files, I just wanted to elaborate a little. The MSDN states that the files are separated with spaces, which is not correct if you use the Explorer style (and you probably want to do that ), they are instead separated with null characters. You can separate them using the Split function
    VB Code:
    1. Dim sFiles() As String
    2. '... other code to show the Open dialog
    3. sFiles = Split(CommonDialog1.FileName, vbNullChar)
    If the user has selected more then one file sFiles(0) will now contain the path to these files and sFiles(1) to sFiles(numberOfFilesSelected) will contain their file names.

    You might also want to change the MaxFileSize property. Despite the name of this property it has nothing todo with the files size on disk but rather the maximum length of the string the FileName property will return. The default value is 256, which is usually fine for selecting only one file, but since you want the user to be able to select more then that you should increase it's value. The max value for this property is 4,294,967,295 which should be more then enough

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