Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to import a table from an access database that is saved on my c
drive and import it into a worksheet.....I keep getting a type mismatch error when I try to set the recordset.....Got any suggestions?....Here is the code I'm using..... Dim DBFullName As String Dim TableName As String Dim FieldName As String Dim TargetRange As Range Dim db As Database Dim rs As Recordset Dim intColIndex As Integer DBFullName = "C:\Documents and Settings\Junior\My Documents\Consumer Loans.mdb" TableName = "tbl_CLC" Set TargetRange = Excel.Application.Worksheets("CLC").Range("A1") Set db = OpenDatabase(DBFullName) Set rs = db.OpenRecordset(TableName, dbOpenTable) ' all records For intColIndex = 0 To rs.Fields.Count - 1 TargetRange.Offset(0, intColIndex).Value = rs.Fields(intColIndex).Name Next ' write recordset TargetRange.Offset(1, 0).CopyFromRecordset rs Set rs = Nothing db.Close Set db = Nothing -- Thanks in advance.... |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Removing Data Tables formed from importing data from Access | Excel Discussion (Misc queries) | |||
Importing from Access | Excel Worksheet Functions | |||
Importing from Access | Excel Discussion (Misc queries) | |||
Importing Tables from Access into Excel using Macros or VBA | Excel Discussion (Misc queries) | |||
Importing Access tables to an Excel worksheet. | Excel Programming |