Excel Database 
Author Message
 Excel Database

I have below a WSH set up to read Access Databases. Is there a similar way
to set up WSH to read an excel spreadsheet? I assume this is still a JET
OLEDB

Access Example:

Dim logConn,logAccess

'logAccess = "Driver={Microsoft Access Driver (*.mdb)};Server="server name"
;DBQ=C:\db1.mdb"
logAccess = "Provider=Microsoft.Jet.OLEDB.4.0; Server="Server name"; Data
Source =C:\db1.mdb"

Set logConn = Server.CreateObject("ADODB.Connection")
logConn.open logAccess



Tue, 05 Oct 2004 23:04:07 GMT  
 Excel Database

Here's a simple example to read cell A1 from a spreadsheet...

Dim xlApp
Dim xlBook
Dim xlSheet

Call ReadExcel()

Sub ReadExcel()
    Set xlApp = WScript.CreateObject("Excel.Application")
    Set xlBook = xlApp.Workbooks.Open("C:\README.XLS")
    Set xlSheet = xlBook.Sheets(1)

    MsgBox xlSheet.Range("A1").Value

    xlBook.Close
    xlApp.Quit

    Set xlSheet = Nothing
    Set xlBook = Nothing
    Set xlApp = Nothing
End Sub


I have below a WSH set up to read Access Databases. Is there a similar way
to set up WSH to read an excel spreadsheet? I assume this is still a JET
OLEDB

Access Example:

Dim logConn,logAccess

'logAccess = "Driver={Microsoft Access Driver (*.mdb)};Server="server name"
;DBQ=C:\db1.mdb"
logAccess = "Provider=Microsoft.Jet.OLEDB.4.0; Server="Server name"; Data
Source =C:\db1.mdb"

Set logConn = Server.CreateObject("ADODB.Connection")
logConn.open logAccess



Wed, 06 Oct 2004 00:02:01 GMT  
 Excel Database
cnn2.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\file.xls;Extended
Properties=Excel 8.0"

Set rsx = CreateObject("ADODB.Recordset")

rsx.Open "Sheet1$", cnn2, adOpenKeyset, adLockReadOnly, adCmdTableDirect

Beware of using the Jet provider with Excel spreadsheets. It looks at the
first five rows in any given column to determine the datatype. So if the
first five have a cell format of text in the spreadsheet and the rest as
numeric you get an error for each numeric value. If you have *any* manual
entry of data into the spreadsheet it becomes easy to get it into a real
mess.

I
--


Quote:
> I have below a WSH set up to read Access Databases. Is there a similar way
> to set up WSH to read an excel spreadsheet? I assume this is still a JET
> OLEDB

> Access Example:

> Dim logConn,logAccess

> 'logAccess = "Driver={Microsoft Access Driver (*.mdb)};Server="server
name"
> ;DBQ=C:\db1.mdb"
> logAccess = "Provider=Microsoft.Jet.OLEDB.4.0; Server="Server name"; Data
> Source =C:\db1.mdb"

> Set logConn = Server.CreateObject("ADODB.Connection")
> logConn.open logAccess



Wed, 06 Oct 2004 00:59:34 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Access/Excel database research project

2. pass data from an Access database form to specific cell in Excel

3. Export Database Query Results to Excel?

4. Problem working database with excel

5. Urgent! How to join excel with database

6. open doc/excel file in frame with Word/Excel menubar

7. Applying Excel Autofilter when opening Excel Files

8. Open Excel File (Excel.Application)

9. Urgent - Check the installation of EXCEL or EXCEL Viewer on Client

10. need help: Open Excel, run macro, save file, close Excel

11. Open Excel File (Excel.Application)

12. Parsing Excel file in a browser window and Excel menubar

 

 
Powered by phpBB® Forum Software