Solved

Populating Excel Ole With ADO Recordset

Posted on 1999-01-06
3
368 Views
Last Modified: 2013-12-25
I have opened an excel worksheet object in my VB application and am attempting to populate it from an ADO recordset, and allow the user to print out the results. What is the method to import the data into the excel chart? When I run the application, all of the usual Excel menu items are there excepr for the File menu, which includes the Print command. How do I allow the user to print the date in the chart after they have formatted it?
0
Comment
Question by:tgoglia
3 Comments
 

Expert Comment

by:T38Jet
ID: 1498790
that's several questions....

' Here's how you plug in the ADO recordset value
objExcel.Application.ActiveWorkbook.Worksheets("Sheet1").Rows(1).Cells(1).Value = rstRecords.Fields("Field1").Value

If your chart is based on a pivot table which gets its data from "Sheet1", it will automatically appear in the chart.

0
 

Author Comment

by:tgoglia
ID: 1498791
Thanks for your help. Your code proved that I had the right idea, the problem was that I thought that when I created the OLE object, I assumed that the appropriate code libraries would automatically be added to the project. An incorrect assumption.
tgoglia
0
 
LVL 3

Accepted Solution

by:
altena earned 200 total points
ID: 1498792
A nice alternative is to create a huge string
using "vbTab" (to separate columns) and "vbCRLF"
to go to the next row.

Then you only have to call a "paste" method in excel
and all of the data will be put in as once.

This is MUCH faster than looping aver the recordset
and putting in the values one by one.

Good Luck.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now