Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default VBA and charts

Hi all. I'm having trouble working with charts in Excel using Visual basic.

What I'm trying to do is take an embedded chart that is selected, copy and paste it, then select the original chart.

The trouble I'm having is that I just can't get visual basic to tell me the index of the active chart!

Msgbox ActiveChart.Index
returns an "Method 'Index' of object '_Chart' failed" error

Msgbox ActiveChart.name
works, but returns "charts Chart 12" for example. This would be fine if I could then use this to refer to the chart later, but I think the extra "charts" is throwing it off

Can anyone offer any help

Eric
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default VBA and charts

This gives the number for the chartObject --

Sub GetIndex()
Dim chObj As ChartObject
Set chObj = ActiveChart.Parent

Debug.Print ActiveSheet _
.ChartObjects(chObj.Name).Index

End Sub


Eric wrote:
Hi all. I'm having trouble working with charts in Excel using Visual basic.

What I'm trying to do is take an embedded chart that is selected, copy and paste it, then select the original chart.

The trouble I'm having is that I just can't get visual basic to tell me the index of the active chart!

Msgbox ActiveChart.Index
returns an "Method 'Index' of object '_Chart' failed" error.

Msgbox ActiveChart.name
works, but returns "charts Chart 12" for example. This would be fine if I could then use this to refer to the chart later, but I think the extra "charts" is throwing it off.

Can anyone offer any help?

Eric



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

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
charts toolbar / charts disappeared Pro Charts and Charting in Excel 0 December 18th 09 01:31 AM
link excel charts to web pages and update charts automatically Signguy Charts and Charting in Excel 1 April 22nd 08 08:29 PM
Charts - How to have multiple charts share a legend. Sean Charts and Charting in Excel 2 November 20th 07 04:49 AM
interactive charts for stacked bar charts [email protected] Charts and Charting in Excel 4 December 28th 06 09:58 PM
Matching the colors Column Charts and Pie Charts RohanSewgobind Charts and Charting in Excel 3 April 21st 06 09:35 PM


All times are GMT +1. The time now is 06:46 AM.

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

About Us

"It's about Microsoft Excel"