Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Common Dialog to select/open multiple files 2

Status
Not open for further replies.

sacsac

Programmer
Joined
Dec 10, 2000
Messages
182
Location
GB
I want to select multiple files using the CommonDialog control. So I call it with code like this:

With MyCommonDialog
.Filter = "All text files (*.txt)|*.txt"
.Flags = cdlOFNFileMustExist Or cdlOFNHideReadOnly Or cdlOFNAllowMultiselect Or cdlOFNLongNames
.ShowOpen
End with

Instead of the usual nice clean looking dialog box I get an old-syle one showing drives, folders and files in separate list boxes, but more importantly the file names are converted to old 8.3 dos-style format (despite the appropriate flags being set). See attached samples.

Any ideas for a neat solution out there?
 
Have you tried it with the [tt]cdlOFNExplorer[/tt] flag?
 
Thanks dilettante. I was not aware of that flag. It seems to do the trick!
I just need to now create some code to parse the string of returned file names and separate them correctly, as the code I was using for the older style dialog did not expect the spaces since long filenames did not exist.

All the best!
 
They should be delimited by a NULL character. Something like this should work to get them into an array. The first element of the array should be the path of the files.


Code:
Dim aryFileNames() As String
aryFileNames = Split(MyCommonDialog.FileName,vbNullChar)

Swi
 
Thanks Swi - that's great. I did not think about vbNullChar because I incorrectly thought that I was looking at 'spaces' between the filenames (which I was then trying to differentiate from spaces within the long filesnames). This is all very simple now.
 
Glad to be of help.

Swi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top