Qopo
04-02-2003, 07:44 PM
hi ppl, I have been stuck by this problems for a fews weeks, I have problem linking vb6 and excel and drawing data from excel.
my code
...........
Dim wbBook As Workbook
Dim sconn As String
Dim wsSheet1 As Worksheet
Dim sfile As String
sfile = App.Path & "\" & "T2C12.xls"
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim rnData As Range, rnCell As Range, rnTarget As Range
rs.CursorLocation = adUseClient
rs.CursorType = adOpenKeyset
rs.LockType = adLockBatchOptimistic
sconn = "DRIVER=Microsoft Excel Driver (*.xls);" & "DBQ=" & sfile
rs.Open "SELECT * FROM [sheet1$]", sconn
Set wbBook = rs
With wbBook
Set wsSheet1 = .Worksheets("Column Load-Taking" )
End With
With wsSheet1
Set rnData = .Range(.Range("A4" ), .Range("A65536" ).End(xlUp))
End With
$$$$$$$$$$$$$$$
my excel sheet also look very strange cos i dun have fields names
A B C D
1 this is a example of a load taking
2
3 floor area height
4
5 1 2 3
6
4
how do i get the data ? For example i want to get all the values under floor
i have try using rs.fields("floor" ) but cannot be done
can someone pls help me. I have upload example of my excel sheet.
my code
...........
Dim wbBook As Workbook
Dim sconn As String
Dim wsSheet1 As Worksheet
Dim sfile As String
sfile = App.Path & "\" & "T2C12.xls"
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim rnData As Range, rnCell As Range, rnTarget As Range
rs.CursorLocation = adUseClient
rs.CursorType = adOpenKeyset
rs.LockType = adLockBatchOptimistic
sconn = "DRIVER=Microsoft Excel Driver (*.xls);" & "DBQ=" & sfile
rs.Open "SELECT * FROM [sheet1$]", sconn
Set wbBook = rs
With wbBook
Set wsSheet1 = .Worksheets("Column Load-Taking" )
End With
With wsSheet1
Set rnData = .Range(.Range("A4" ), .Range("A65536" ).End(xlUp))
End With
$$$$$$$$$$$$$$$
my excel sheet also look very strange cos i dun have fields names
A B C D
1 this is a example of a load taking
2
3 floor area height
4
5 1 2 3
6
4
how do i get the data ? For example i want to get all the values under floor
i have try using rs.fields("floor" ) but cannot be done
can someone pls help me. I have upload example of my excel sheet.