|
-
May 5th, 2005, 03:52 PM
#1
Thread Starter
Fanatic Member
Multiple Select
I want to select multiple files from Common Dialog ...
How to do it ...?
-
May 5th, 2005, 03:54 PM
#2
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
May 5th, 2005, 04:19 PM
#3
Thread Starter
Fanatic Member
Re: Multiple Select
hi Rob..
now i also want to retrieve filenames separately as well..
-
May 5th, 2005, 04:28 PM
#4
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:
Dim sFiles() As String
'... other code to show the Open dialog
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|