Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Referencing an Excel Chart in VBA

The OLE Object in the Excel Chart Object is actually a workbook, not just a
chart (took me a while to figure this out!). The book has two sheets - one a
regular data sheet, the other a chart sheet.

Add the "Microsoft Excel Object Model" to your project's references, then:

Dim myBook as Excel.Workbook
Dim DataSheet as Excel.Worksheet
Dim myChart as Excel.Chart
etc.. (add any other Excel objects, like Excel.Range objects, you may need
to use)

Set MyBook = Forms("MyFormName").ChartControlName.Object
Set DataSheet = MyBook.Sheets("Sheet1")
Set myChart = MyBook.Charts(1)

Now you can refer to the regular Excel objects, properties and methods by
using your object variables.

HTH!
K Dales

" wrote:

I am working on a form in MS Access. In design mode I click on Insert
| Object from the main menu. Then I select Microsoft Excel Chart.
This puts a new Excel chart on my Access form (it seems to have some
default data). Now I want to use VBA to modify this chart at run time.
However I have no idea how to reference the chart in code. Let's say
that I name the control myChart. In code when I inspect the properties
and methods of myChart it seems to be just some generic object
properties and methods. Is this object some sort of OLE container or
something? I don't know very much about how it works when you insert
another object on to an Access form (or VB form for that matter). Is
there some magic way that I have to reference the object so that I can
get at the Excel object model? Do I have to create an instance of the
Excel Application and then get at it that way? If so, how do I
ultimately reference myChart to change its properties?
Thanks,
Corey Burnett



Reply
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
Cross-referencing dates in Excel gantt chart Karl Excel Worksheet Functions 4 January 12th 09 02:30 PM
chart referencing Anto111 Excel Discussion (Misc queries) 0 July 15th 08 05:29 PM
excel chart - absolute referencing????! Red_Star20 Charts and Charting in Excel 1 June 21st 07 05:59 PM
Referencing chart sheets in vba The Big Smelly Ogre Charts and Charting in Excel 1 February 1st 06 06:37 PM
Referencing Excel.Chart.8 OLE Object in Access Report OJFEnterprises Excel Programming 6 November 15th 04 08:54 PM


All times are GMT +1. The time now is 12: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"