Hi Sagar Just check following code,
excel file is opened as a adodb connection, then u can manipulate as u want
Dim cn As ADODB.Connection
Dim rsT As New ADODB.Recordset
Dim tblList As ADODB.Recordset
Dim I As Integer
Private Sub cmdImport_Click()
List1.Clear
rsT.Open "select * from [" & cmbSheetName.Text & "]", cn, adOpenDynamic, adLockReadOnly
Do While Not rsT.EOF
If IsNull(rsT.Fields(5)) = False Then
List1.AddItem rsT.Fields(5) & ""
End If
rsT.MoveNext
Loop
rsT.Close
End Sub
Private Sub cmdOpenFile_Click()
cDiag.Filter = "*.xls"
cDiag.Action = 1
txtFileName.Text = cDiag.FileName
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=" & txtFileName.Text & _
";Extended Properties=Excel 8.0;"
.CursorLocation = adUseClient
.Open
End With
Set tblList = cn.OpenSchema(adSchemaTables)
For I = 1 To tblList.RecordCount
cmbSheetName.AddItem tblList.Fields("TABLE_NAME").Value & ""
tblList.MoveNext
Next I
cmbSheetName.ListIndex = 0
End Sub
Private Sub Form_Load()
Set cn = New ADODB.Connection
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
' cn.Close
End Sub