加入 try catch
Dim dlg As New OpenFileDialog
dlg.Filter= "Excel 97-2003文件(*.xls)|*.xls|Excel 2007文件(*.xlsx)|*.xlsx"
If dlg.ShowDialog = DialogResult.Ok Then
Dim cmb1 As WinForm.ComboBox = e.Form.Controls("ComboBox1")
Dim txtb1 As WinForm.TextBox = e.Form.Controls("TextBox1")
txtb1.value = dlg.FileName
cmb1.Value = ""
If txtb1.Value > "" Then
try
Book = New XLS.Book(txtb1.value)
cmb1.items.clear
Dim str(Book.Sheets.count - 1) As String
Dim Sheet As XLS.Sheet
For i As Integer = 0 To Book.Sheets.count - 1
str(i) = Book.Sheets(i).name ' str.add(Book.Sheets(i).name)
Next
cmb1.Items.AddRange(str)
catch ex As exception
msgbox("打开excel文件出错")
End try
End If
cmb1.Select()
End If