PRMiller2
Technical User
- Jul 30, 2010
- 123
I am using the code referenced over at to allow users to select multiple files. The code calling the dialog box is as follows:
The code works except with particular files. In other words, a user can select multiple files without an error. However, when selecting certain files, they receive an error: "Error 13: Type mismatch."
The files to be selected are:
COMPANYMAILAUDIT_07_01_074036_001.XLS
COMPANYMAILAUDIT_07_01_074036_002.XLS
COMPANYMAILAUDIT_07_01_074036_003.XLS
COMPANYMAILAUDIT_07_01_074036_004.XLS
COMPANYMAILAUDIT_07_01_074036_005.XLS
COMPANYMAILAUDIT_07_01_074036_006.XLS
COMPANYMAILAUDIT_07_01_074036_007.XLS
COMPANYMAILAUDIT_07_01_074036_008.XLS
COMPANYMAILAUDIT_07_01_074036_009.XLS
COMPANYMAILAUDIT_07_01_074036_010.XLS
COMPANYMAILAUDIT_07_01_074036_011.XLS
COMPANYMAILAUDIT_07_01_074036_012.XLS
COMPANYMAILAUDIT_07_01_074036_013.XLS
COMPANYMAILAUDIT_07_01_074036_014.XLS
COMPANYMAILAUDIT_07_01_074036_015.XLS
All files are formatted exactly the same, and files 001 - 014 are 55,000 KB. The 15th one is 14 KB.
The type mismatch occurs when selecting any one file by itself. However, when more than one file is not selected, the error does not occur... unless more than 5 files are selected, in which case it does.
Stepping through the code, VB executes ahtCommonFileOpenSave and appears to exit the function normally. However, as soon as it returns to the calling sub, it generates the error.
I'm baffled as to what's going on... any suggestions?
Code:
Private Sub Test_Click()
On Error GoTo Err_Handler
Dim intCounter As Integer
Dim intFileCount As Integer
Dim lngFlags As Long
Dim strFilter As String
Dim strInitialDir As String
Dim strFiles() As String
strInitialDir = "C:\Documents and Settings\prmiller\My Documents\Master Docs"
strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)", "*.XLS")
lngFlags = ahtOFN_ALLOWMULTISELECT Or ahtOFN_EXPLORER
strFiles = ahtCommonFileOpenSave(InitialDir:=strInitialDir, _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select one or more input files:", _
Flags:=lngFlags)
If Not IsNull(strFiles) Then
If IsArray(strFiles) Then
intFileCount = UBound(strFiles)
For intCounter = 0 To intFileCount
' Call PricingQA(intCounter)
Next intCounter
Else
' Call PricingQA(intCounter)
End If
End If
Exit_Handler:
Exit Sub
Err_Handler:
Call LogError(Err.Number, Err.Description, "mdlPricingQA.Test_Click()")
Resume Exit_Handler
End Sub
The code works except with particular files. In other words, a user can select multiple files without an error. However, when selecting certain files, they receive an error: "Error 13: Type mismatch."
The files to be selected are:
COMPANYMAILAUDIT_07_01_074036_001.XLS
COMPANYMAILAUDIT_07_01_074036_002.XLS
COMPANYMAILAUDIT_07_01_074036_003.XLS
COMPANYMAILAUDIT_07_01_074036_004.XLS
COMPANYMAILAUDIT_07_01_074036_005.XLS
COMPANYMAILAUDIT_07_01_074036_006.XLS
COMPANYMAILAUDIT_07_01_074036_007.XLS
COMPANYMAILAUDIT_07_01_074036_008.XLS
COMPANYMAILAUDIT_07_01_074036_009.XLS
COMPANYMAILAUDIT_07_01_074036_010.XLS
COMPANYMAILAUDIT_07_01_074036_011.XLS
COMPANYMAILAUDIT_07_01_074036_012.XLS
COMPANYMAILAUDIT_07_01_074036_013.XLS
COMPANYMAILAUDIT_07_01_074036_014.XLS
COMPANYMAILAUDIT_07_01_074036_015.XLS
All files are formatted exactly the same, and files 001 - 014 are 55,000 KB. The 15th one is 14 KB.
The type mismatch occurs when selecting any one file by itself. However, when more than one file is not selected, the error does not occur... unless more than 5 files are selected, in which case it does.
Stepping through the code, VB executes ahtCommonFileOpenSave and appears to exit the function normally. However, as soon as it returns to the calling sub, it generates the error.
I'm baffled as to what's going on... any suggestions?