Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read Excel without Excel Installed

Status
Not open for further replies.

aco636

IS-IT--Management
Nov 25, 2003
212
GB
Hi there

As always any help gratefully received.

Looking fr some ideas to read excel without installing excel app. Did try to set up ODBC DSN but am having trouble.

Dont have any preference on connection method but....
I must be able to move around just like any other database connection.

Thanks in advance ACO
 
Try this code. You'll need to change the strDrv and strDB to fit your system. strDrv is the file path and strDB is the Excel file you want to open. I create a text file where it places the value of Column A. Hope this helps.

Regards,

mapman04

---------------------------

Dim strDrv,strDB,strLog,bst

strDrv= "S:\Data\"
strDB = strDrv & "Excel.Xls"
strLog = strDrv & "ExcelExt.Txt"

Set db = CreateObject("ADODB.Connection")
dbStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
dbStr = dbStr & strDB & ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"""
db.Open dbStr

Set bst = CreateObject("ADODB.RecordSet")
bst.CursorType = 1
bst.LockType = 3

strSQL = "SELECT * FROM [sheet1$]"

bst.Open strSQL, db

If bst.EOF = False Then

bst.MoveLast
bst.MoveFirst

Set fso = Wscript.CreateObject("Scripting.FileSystemObject")
Set txt3 = fso.CreateTextFile(strLog,True)

Do While bst.EOF = False

strTag = bst.Fields("ColumnA")

txt3.WriteLine(strTag)

bst.MoveNext

Loop
End If

bst.Close
db.Close
txt3.Close

MsgBox "Done!",64,"Finished"
Wscript.Quit
 
Sorry to take so long to respond, have not been on for a few days. Will try your code and let you know
regards ACO
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top