''' Set the Color to the Cells in Excel
Set xl = CreateObject("Excel.Application")
xl.Visible = True
xl.Workbooks.Add
For i = 1 to 56
xl.Cells(i, 1).Value = i
xl.Cells(i, 1).Interior.ColorIndex = i
Next
''Read Data from MS-Excel using ADODB.Connection and RecordSet
'' Take few records of emp details in cells A1 to C4 for practise like eno, ename,sal
Dim cn,sSQL,rs,vRows, strtext
Set cn=CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
cn.open "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=e:\gvenkat\data.xls ;Extended Properties=Excel 8.0"
rs.open "SELECT * FROM [Sheet1$A1:c4]", cn
i=0
while rs.eof<>True
for each field in rs.fields
if Trim(strtext)="" then
strtext=strtext & field.value
else
strtext=strtext & " " & field.value
end if
next
i=i+1
rs.moveNext()
Wend
rs.close
cn.close
vRows=Split(strtext,vbTab)
For i=0 to ubound(vRows)
print vRows(i)
Next
This is a wonderful post! Thanks for sharing your knowledge with us! I hope to read more of your post which is very informative and useful to all the readers. I salute writers like you for doing a great jobexcel programmer
ReplyDelete