Gallowgate
Technical User
hi All
Firstly, I'm a beginner with VB. Got the following out of a book and works when I select some files, however, when I choose Cancel in the Openfile Dlg, it returns msg 'Error 13: Type mismatch' on the FOR loop. How can I check if the array is empty(ie no files selected or cancel was pressed). In the debugger, fname equals 'false' when cancel is pressed, why is it false?
thanks for any help
Martin
Firstly, I'm a beginner with VB. Got the following out of a book and works when I select some files, however, when I choose Cancel in the Openfile Dlg, it returns msg 'Error 13: Type mismatch' on the FOR loop. How can I check if the array is empty(ie no files selected or cancel was pressed). In the debugger, fname equals 'false' when cancel is pressed, why is it false?
Code:
Const iTitle = "Pick file"
Const Filterlist = _
"Word(*.doc), *.doc, Excel(*.xls), *.xls"
Dim i As Integer
With Application
Fname = .GetOpenFilename(Title:=iTitle, _
filefilter:=Filterlist, _
FilterIndex:=2, _
MultiSelect:=True)
End With
For i = LBound(Fname) To UBound(Fname)
tbfilename.Text = tbfilename.Text & Fname(i) & "; "
Next i
thanks for any help
Martin