LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default How to populate Excel Range from Access RecordSet?

I have code that loops through about 40 Access mdbs and sucks in a bunch of
data into one internal Access table. The challenge now is getting that data
out of Access and into an Excel Worksheet. I've tried
DoCmd.TransferSpreadsheet - not the solution I need.

This is the kind of thing I'm looking for:

xlapp.Workbooks(strXlsFile).Worksheets(j + 1).CopyFromRecordset rst
xlapp.Workbooks(strXlsFile).Worksheets(j + 1).CurrentRegion.Columns.AutoFit

I want to dump whatever is in the rst into a blank Worksheet.

Can someone help me with syntax or other suggestions?

Thanks!

Here's more complete code if you're interested:

For Each fldSub In fld.SubFolders
strSheetName = fldSub.Name
strMdbPath = fld & "\" & strSheetName & "\MEAN.MDB"
If LinkTable(strMdbPath, strXlsPath) Then
db.Execute strSql, dbFailOnError
Set rst = db.OpenRecordset("tblMean")
j = xlapp.Workbooks(strXlsFile).Worksheets.Count

xlapp.Workbooks(strXlsFile).Worksheets.Add(After:= xlapp.Workbooks _
(strXlsFile).Worksheets(j)).Name = strSheetName
xlapp.Workbooks(strXlsFile).Worksheets(j + 1).CopyFromRecordset
rst
xlapp.Workbooks(strXlsFile).Worksheets(j +
1).CurrentRegion.Columns.AutoFit
k = k + 1
End If
xlapp.Workbooks(strXlsFile).Save
Next fldSub

It took me a while to figure out this syntax:

xlapp.Workbooks(strXlsFile).Worksheets.Add(After:= xlapp.Workbooks(strXlsFile
).Worksheets(j)).Name = strSheetName

but it seems to be working now


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Repost! Excel multiple worksheet populate from recordset B[_3_] Excel Programming 1 November 6th 04 10:56 AM
Help! Excel multiple worksheet populate from recordset B[_3_] Excel Programming 1 November 5th 04 09:59 AM
Acquiring a single recordset from Access into Excel Humsel Excel Programming 2 September 1st 04 07:04 AM
How to populate a multi-column activeX listbox on a spreadsheet with an ADO recordset quartz Excel Programming 1 May 3rd 04 10:13 PM
open range (within workbook) as ado recordset - excel vba S. Daum Excel Programming 0 July 25th 03 04:45 PM


All times are GMT +1. The time now is 08:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"