Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2004
    Posts
    39

    Question Unanswered: Changing Chart Data Source of Excel

    Hi,
    Actually I'm exporting data from access database to excel workbook automatically. I have done many calculations to the data. But now the problem is there is a chart in the workbook and I need to add my new data which is one row to the chart's source data.
    Can anyone help me out with any functions relating to charts that can be coded in access.
    Thanks.

  2. #2
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    Run your program up to the point where there's data in Excel and the chart is ready (I assume you're working with a template or an existing file).

    Now, go into Excel and under tools, start recording a Macro in the local workbook. Then, manally do exactly what you want the code to do.

    When you're done, stop recording and peek inside the Macro Editor. What you'll find is the code that covers everything you just did.

    It will undobtedly need some weeding out so that you end up with only what you want, but the last step is pretty easy.

    Back in Access, Dim a variable as Excel.Application and copy the code from Excel into Access. Surround your Excel code using a "With Object Set" as shown here:

    If your object variable is objExcel then before the Excel code, add With objExcel
    Then, put a period before every Excel unique command (Worksheet, Application, etc.)
    At the end of the Excel code, add End With

    A few trips through the debugger and you'll be all set.


    have fun!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •