Solved

How to handle a large number of multiselected files with the VB6 common dialog?

Posted on 2004-04-07
8
441 Views
Last Modified: 2012-06-22
With multi-select, I use these settings for the VB6 common dialog
   
CommonDialog3.flags = cdlOFNAllowMultiselect Or cdlOFNFileMustExist Or cdlOFNExplorer
CommonDialog3.MaxFileSize = 10240

Beyond about 50 files selected, the files don't get identified. and therefore processeed. If I increase the MaxFileSize by a large amount, things freeze up.

Is there a workaround, or a way to warn the user not to select so many files, or am I missing something in my code?

From the experts, advice please!
0
Comment
Question by:Gordon_Atherley
8 Comments
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 10776655
I just selected about 600 with no problems using what you did (flags and maxfilesize). Using version 6.0 of the control (SP3)..

Private Sub Form_Load()
    Dim sSplit() As String
    CommonDialog1.Flags = cdlOFNAllowMultiselect Or cdlOFNFileMustExist Or cdlOFNExplorer
    CommonDialog1.MaxFileSize = 10240
    CommonDialog1.ShowOpen
    sSplit = Split(CommonDialog1.FileName, Chr(0))
    MsgBox UBound(sSplit)
End Sub
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 10777338
what sp you are using?

the max number for MaxFileSize is 32k
0
 

Author Comment

by:Gordon_Atherley
ID: 10779250
Thanks

SP 5

The 32k limit explains the problem I am running into. Are there any ways to effectively extend this or to warn users to limit their selections to a particular number? Even so, this would be a nuisance because it's not easy for the user to count the number of files selected.
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 17

Accepted Solution

by:
zzzzzooc earned 250 total points
ID: 10780063
>> it's not easy for the user to count the number of files selected.

More so the length of all of the files selected. Your files must be really deep inside folders for you to go over 32k file length from under 50 selected files. I can select a couple thousand files in the system32 directory ok.

Anyways.. you could error-handle it and warn the users by the dialog title..  just an idea.. :P

Private Sub Command1_Click()
    On Error Resume Next
    Dim sArray() As String
    With CommonDialog1
        .DialogTitle = "Open file..."
        .Flags = cdlOFNAllowMultiselect Or cdlOFNExplorer
        .InitDir = "c:\windows\system32\"
        .MaxFileSize = 3200
OpenAgain:
        Call .ShowOpen
        'May not be the same Err # for you..
        If Err.Number = 20476 Then
            .DialogTitle = "Too many files selected. Try again."
            .FileName = vbNullString
            Err.Clear
            GoTo OpenAgain
        Else
            If .FileName <> vbNullString Then
                sArray = Split(.FileName, vbNullChar)
                MsgBox UBound(sArray)
                .FileName = vbNullString
            End If
        End If
    End With
End Sub

0
 
LVL 3

Expert Comment

by:redfordb
ID: 10782422
If the problem persists, create your own dialogue.
0
 

Author Comment

by:Gordon_Atherley
ID: 10782431
Thanks, zzzzzzooc, just what I was looking for.

The files are deep inside folders. Even so, I can't see how they create a file 32k in size. I've still to figure out that puzzle. But the two stage error handler solves the immediate problem.

0
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 10787798
Oh.. it's not a matter of the length of one file. More so the combined length of all selected files being over 32k. It's still hard imagining the files being about 500+ characters long each though. :o
0
 

Author Comment

by:Gordon_Atherley
ID: 10787825
Agreed.
I'm going to explore further. If I find anything useful, I'll post it. :G
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel VBA combine two working workbooks 8 53
Run code from text file in vb 1 64
vb6 connector to SQL Server 2 37
SQL VB connection works in one PC and doesn't in another 15 64
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now