Thursday 15 May, 2008

Connecting Excel and Checking values

Filename = "c:\sample.xls"
MyWorkSheet = "[Sheet1$]" 'special syntax, sheet name is test

ActiveCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
ActiveCon = ActiveCon & Filename
ActiveCon = ActiveCon & ";Extended Properties=""Excel 8.0;HDR=NO;IMEX=1;"""

set rsExcel = CreateObject("ADODB.Recordset")
rsExcel.LockType = 1
rsExcel.ActiveConnection = ActiveCon

rsExcel.Open "Select * from " & MyWorkSheet

msg = ""

for j = 0 to rsExcel.fields.count -1
msg = msg & rsExcel.fields(j).name & " "
next

msg = msg & vbcrlf
msg = msg & vbcrlf

do while not rsExcel.eof
for j = 0 to rsExcel.fields.count -1
msg = msg & rsExcel.fields(j) & " "
next
msg = msg & vbcrlf
rsExcel.movenext
loop
rsExcel.close
msgbox msg

3 comments:

Anonymous said...

גן מומלץ במרכז : גן פיציקטו !
! פשוט גן מדהים שוש ומוני מדהימים,
עושים עבודה מדהימה עם הילדים!

, איכות זאת לא מילה גסה.

Feel fгee to visit my hоmepаge המלצה לגן פרטי

Anonymous said...

Ӏ quite like геadіng thrоugh а post that can mаke pеoρle think.
Аlѕo, thank you for allowіng me to comment!


Ηere is my ωеblog - buy comodynes self tanning online

Anonymous said...

May I juѕt say what a cοmfort to diѕcovеr sοmeone that rеally undегѕtands what
they're talking about online. You certainly know how to bring a problem to light and make it important. More people have to check this out and understand this side of the story. I can't bеlieve you're not more popular since you definitely possess the gift.

Here is my web site: fake bake flawless review