Access to Excel
I need to get a table from MS Access into MS Excel in Office 2003, any
suggestions |
Access to Excel
try:
In Excel: Data=Import External Data=Import Data Select your Access Data base and then required table. "Josh C" wrote: I need to get a table from MS Access into MS Excel in Office 2003, any suggestions |
Access to Excel
I have a code example on this page that use ADO
http://www.rondebruin.nl/accessexcel.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "Toppers" wrote in message ... try: In Excel: Data=Import External Data=Import Data Select your Access Data base and then required table. "Josh C" wrote: I need to get a table from MS Access into MS Excel in Office 2003, any suggestions |
Access to Excel
Try this something like this
replace FIELDNAME's and MyTable with your own also change path to database Private Sub QueryAccessDB() Dim cnn As ADODB.Connection Dim rs1 As ADODB.Recordset Dim strSQL1 As String, strConn Dim i As Integer i = 1 'Use for Access (jet) strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" _ & "Data Source=C:\PathTo\Database\" _ & "MyDatabaseName.mdb;Persist Security Info=False" 'Use for jet strSQL1 = "SELECT MyTable.FIELDNAME1, MyTable.FIELDNAME2, MyTable.FIELDNAME3, " _ & "MyTable.FIELDNAME4, " _ & "FROM MyTable; " Set cnn = New ADODB.Connection Set rs1 = New ADODB.Recordset cnn.Open strConn rs1.Open strSQL1, cnn, adOpenForwardOnly, adLockReadOnly Do While rs1.EOF = False Sheets("Sheet1").Range("A" & i) = rs1!FIELDNAME1 Sheets("Sheet1").Range("B" & i) = rs1!FIELDNAME2 Sheets("Sheet1").Range("C" & i) = rs1!FIELDNAME3 Sheets("Sheet1").Range("D" & i) = rs1!FIELDNAME4 ' Sheets("Sheet1").Range("E" & i) = rs1!FIELDNAME5 ' Sheets("Sheet1").Range("F" & i) = rs1!FIELDNAME6 ' Sheets("Sheet1").Range("G" & i) = rs1!FIELDNAME7 ' Sheets("Sheet1").Range("H" & i) = rs1!FIELDNAME8 i = i + 1 rs1.MoveNext Loop rs1.Close cnn.Close End Sub "Josh C" wrote: I need to get a table from MS Access into MS Excel in Office 2003, any suggestions |
All times are GMT +1. The time now is 10:17 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com