Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Charting / February 2004

Tip: Looking for answers? Try searching our database.

How to export multiple charts from Access

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ian Millward - 11 Feb 2004 08:55 GMT
I need to export several tables and charts from an Access 2000 db into Excel
2000 because Access is very limited for displaying Charts. Ideally, I would
like to group data of a similar nature on the same sheet, tables down the
left side in blocks and charts adjacent. I can't seem to manage that.

The best I can do is one table of data per sheet. I can live with that but
the problem is that all the charts seem to go onto "Sheet1" and stack-up on
top of each other. I have played all the various combinations of
ActiveChart.Location and ActiveChart.SetSourceData but all to no avail. It
works fine if I import the tables into Excel and handraulically create the
charts but not using VBA, although this is not an acceptable option.

My question is: Am I trying to defy the laws of nature by trying to do
something Excel can't do or have I just not hit the correct permutation of
possibilities

Many thanks,

Ian Millward

Edinburgh
Ian Millward - 11 Feb 2004 23:53 GMT
Disregard.

I have just found the definitive answer on MS KB Page.

It is a bug and cannot be done.
M - 12 Feb 2004 17:29 GMT
I have a VBScript that may help you. The code imports a
recordset into a .XLS and generates a chart based on the
<.usedrange>. I use it as a basic template for larger
jobs, and maybe you will find it useful too. Sorry for the
bad textwrap.

M

'*---ADO Connection for ChartScript
'*---By: M. Mills 02/12/2004
'*---Imports data from Access.mdb and generates
'*---a chart in Excel.
'*---------------------------------

dim con       
dim rst
dim rng
dim strCon
dim strSQL
   

    strCon = "Provider=Microsoft.Jet.OLEDB.4.0; " _
            &"Data Source=C:\Test.mdb"
           
    set con = CreateObject("ADODB.Connection")
    set rst = CreateObject("ADODB.Recordset")

        con.Open strCon
   
    '*---Establish the SQL statement
    strSQL = "SELECT * INTO
Excel8.0;Database=C:\Drive.xls].[Drive] FROM Query2"
       
    set rst = con.Execute(strSQL)
   
    '*---Release Access and close connection
    Set con = Nothing
    Set rst = Nothing       
       
    '*---Open Excel and generate chart based on the
imported data   

    Set excel=CreateObject("Excel.Application")
        excel.WorkBooks.Open "c:\Drive.xls"
        excel.application.visible = true
   
    '*---Delete the imported Field Names
    Set rng = excel.Worksheets(1).Range("A1:C1")

        rng.Select
        rng.Delete
   
        excel.Worksheets(1).usedrange.select

    '*---Set up the chart
    Set MyChart = Excel.Charts.Add()
        MyChart.ChartType = 55
        MyChart.SeriesCollection(2).Name = "=""Y
Axis Title"""           
        MyChart.SeriesCollection(1).Name = "=""X
Axis Title"""
       
'*---Basic chart properties
        With MyChart
               .HasTitle = True
          
    .ChartTitle.Characters.Text= "Whatever1"
               .Axes(1).HasTitle = True
               .Axes(1).AxisTitle.Characters.Text
= "Whatever2"
               .Axes(3).HasTitle = False
               .Axes(2).HasTitle = True
               .Axes(2).AxisTitle.Characters.Text
= "Whatever3"
           End With

    '*---Save the chart
    Excel.ActiveWorkbook.SaveAs "C:\MSGraph_Test.xls"

>-----Original Message-----
>Disregard.
[quoted text clipped - 4 lines]
>
>.
Ian Millward - 13 Feb 2004 23:36 GMT
Many thanks,

That will do nicely

> I have a VBScript that may help you. The code imports a
> recordset into a .XLS and generates a chart based on the
[quoted text clipped - 82 lines]
> >
> >.
Tushar Mehta - 13 Feb 2004 04:10 GMT
I'd be interested in what reference you found in the MSKB that led you
to conclude what you want cannot be done.

From your description of the task it is eminently doable.

Signature

Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

> Disregard.
>
> I have just found the definitive answer on MS KB Page.
>
> It is a bug and cannot be done.
Ian Millward - 13 Feb 2004 23:36 GMT
> I'd be interested in what reference you found in the MSKB that led you
> to conclude what you want cannot be done.
>
> From your description of the task it is eminently doable.

Try Article 245089
Jon Peltier - 16 Feb 2004 13:16 GMT
The article says

"RESOLUTION
To work around this problem, do not use the Location method. Instead,
use the Add method to add the embedded chart to the ChartObjects
collection."

This is one of the suggestions I very frequently make, not to solve
particular problems, but to simplify the chart automation process.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
http://PeltierTech.com/Excel/Charts/
_______

>>I'd be interested in what reference you found in the MSKB that led you
>>to conclude what you want cannot be done.
>>
>>From your description of the task it is eminently doable.
>
> Try Article 245089
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.