LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Is it possible to insert an Access Table object into Excel?

onedaywhen wrote:
Jake,
Interesting. I didn't know that the 5K limit (as mentioned in Q246335)
no longer applies. I have my own (now little used) CopyFromRecordset
variation which uses your suggested 'error handling' approach i.e. if
Application.Transpose causes an error then do it the long way. I just
tested it with a 65536x10 results set: no limitation was reached but I
gave up waiting for the 'long way' to finish!


Likewise, I didn't know (or more likely, I forgot) that the limitation was
no longer there in 2002 and up. But like I said, with a long varchar
column, I ran into another limit anyway. <g

One thing I've considered (but haven't got round to building a proper
example) is to use the recordset's 'pages' e.g. some quick code:

With rs
.ActiveConnection = Con
.CursorType = adOpenStatic
.Source = "SELECT MyCol1 FROM TakesMuchTime"
.Open
.PageSize = 65535
' Interate through Pages somehow!
' e.g. to do the last page:
.AbsolutePage = .PageCount
Sheet1.Range("A2").CopyFromRecordset rs
End With

Depends on the data but one way of iterating through the pages would
be to Sort/ORDER BY on a key column (or columns), iterate pages using
.AbsolutePage, get the key column values for the first rows of each
page, then on a second pass use the key values in the Filter method to
limit the rs to 65536 (or less) for CopyFromRecordset on each
iteration. Rather than two passes, it would be easier to Clone the
recordset and use the two recordsets side-by side when filtering, of
course.


I used the PageSize and PageCount properties to find the number of
worksheets needed, but I couldn't think of a good way to do the second part.
So that's why I used a GetRows, as it gave me what I was looking for
(allowed me to fetch the next <PageSize rows). Doing a CopyFromRecordset
would be ideal here, though. If you had control over the data, then you
could obviously use some type of key column as you mentioned, then use a
Filter that gives you the next <PageSize rows, Clone the Recordset, then
use CopyFromRecordset to dump the data to the worksheet. Hmmm, I'll have to
think about that a bit more to see how it could be extended for data sources
you *don't* have control over.

A little project for one day when I've more time on my hands,
methinks.


That's always the problem, isn't it? <sigh

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]

 
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
I can't insert object (email) into excel Toad Excel Discussion (Misc queries) 1 April 1st 08 10:40 PM
Excel Hyperlink to specific Access object Karla V Excel Discussion (Misc queries) 0 July 1st 05 02:35 PM
Access privilege problem with Excel object Wellie Setting up and Configuration of Excel 0 April 8th 05 01:35 PM
Is it possible to insert an Access Table object into Excel? GJones Excel Programming 0 May 4th 04 02:35 PM
Access Object causes an error in excel Bharat[_3_] Excel Programming 2 October 9th 03 09:02 PM


All times are GMT +1. The time now is 01:28 AM.

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

About Us

"It's about Microsoft Excel"