VB提供的对话框可提供多文件提取,我这有段程序: CommonDialog1.Flags = &H200& CommonDialog1.Action = 1 CommonDialog1.filename = CommonDialog1.filename & Chr(32) z = 1 For i = 1 To Len(CommonDialog1.filename) i = InStr(z, CommonDialog1.filename, Chr(32)) If i = 0 Then Exit For ReDim Preserve file(y) file(y) = Mid(CommonDialog1.filename, z, i - z) z = i + 1 If y = 0 Then cpath = file(0) '第一行为目录 endif y = y + 1 Next
同意上面的看法Function SelectMultipleFiles(CD As CommonDialog, Filter As String, Filenames() As String) As Boolean On Error GoTo ExitNow
CD.Filter = "All files (*.*)|*.*|" & Filter CD.FilterIndex = 1 CD.Flags = cdlOFNAllowMultiselect Or cdlOFNFileMustExist Or cdlOFNExplorer CD.DialogTitle = "Select one or more files" CD.MaxFileSize = 10240 CD.FileName = ""
Const OFN_EXPLORER = &H80000ofn.flags = OFN_EXPLORER Or OFN_ALLOWMULTISELECT
.lpstrFile = Space$(32000)
.nMaxFile = 32000
CommonDialog1.Action = 1
CommonDialog1.filename = CommonDialog1.filename & Chr(32)
z = 1
For i = 1 To Len(CommonDialog1.filename)
i = InStr(z, CommonDialog1.filename, Chr(32))
If i = 0 Then Exit For
ReDim Preserve file(y)
file(y) = Mid(CommonDialog1.filename, z, i - z)
z = i + 1
If y = 0 Then
cpath = file(0)
'第一行为目录
endif
y = y + 1
Next
On Error GoTo ExitNow
CD.Filter = "All files (*.*)|*.*|" & Filter
CD.FilterIndex = 1
CD.Flags = cdlOFNAllowMultiselect Or cdlOFNFileMustExist Or cdlOFNExplorer
CD.DialogTitle = "Select one or more files"
CD.MaxFileSize = 10240
CD.FileName = ""
CD.CancelError = True
CD.ShowOpen
Filenames() = Split(CD.FileName, vbNullChar)
SelectMultipleFiles = TrueExitNow:
End Function