Excel Chart VBA Examples and Tutorials – Chart Collection in Excel VBA. (“Chart 1”).Activate. Free Project Management Templates Excel 2007 – Project. I've used the attached code to retrieve some data from the sheet, clear a bunch of cells to reset the sheet and reset a graph (the graph itself is.
Excel 2000
Windows XP
I have a workbook that opens another workbook, copies a worksheet into that workbook and runs functions from the copied worksheet. All of this works as expected until I try to activate a chart object within one of the functions.
To try and be more clear as to what the process is:
- Workbook A contains Worksheet B that contains code.
- Workbook A contains code that opens Workbook X and copies Worksheet B into Workbook X.
- Workbook A then calls a function from the copied version of Worksheet B in Workbook X. This is where the code fails.
I've tried different sytax to activate the chart, all of which yeild the same stinking error 'Activate method of ChartObject class failed'.
Here are a few different ways I've tried to activate the sheet:
I've also done this:
I get a message box for each chart including 'Chart 3'.
And yes, it is absolutely necessary that one workbook opens another the way I described in the first paragraph.
Activates the ChartObject named Chart 1
Related examples in the same category
1. | Creating a New Chart Using the ChartWizard Method |
2. | Creating a Chart Using the Chart Object |
3. | Creating a Chart |
4. | Creating a Chart on an Existing Worksheet |
5. | Specifying the Source Data for the Chart by using the SetSourceData method of the Chart object |
6. | Specifying the Chart Type |
7. | Adding a New Series to the chart identified by the object variable myChart, drawing the data from the range C4:K4 on the active worksheet in the active workbook, using rows: |
8. | Extending an Existing Series in the chart identified by the object variable myChart using the data in the cells P3:P8 on the worksheet named Chart Data: |
9. | Creating a New Series, use the NewSeries method with the SeriesCollection collection. |
10. | Creating Charts |
11. | Creating an Embedded Chart |
12. | Add Chart |
13. | Select a chart object |
14. | Get Chart sheet |
15. | Reference Char object from ActiveSheet |
16. | Get Embedded Charts |
17. | Inserts a chart before each sheet |
18. | Inserts a chart before each sheet 2 |
19. | Determining a chart's source data |
20. | Get Chart SeriesCollection value |
21. | Retrieving data point labels from field names in the worksheet |
22. | Show chart |
23. | Automatically generating a chart without user interaction |
24. | Producing an Excel worksheet on a Word 2000 document |
25. | Insert two chart sheets after the last worksheet in the active workbook. The chart sheets receive default names, such as Chart1 and Chart2: |
26. | Use For Each to loop through all chart objects |
27. | Modifying the chart type |
28. | To ensure that a chart is selected, you can add a statement to determine if a chart is active. |
29. | In most cases you can avoid using the worksheet Index property |
30. | Insert chart sheets after each worksheet |
31. | Adding a Chart Sheet Using VBA Code |
32. | convert an existing chart to use arrays instead of cell references and make it independent of the original data |
33. | add the data labels using the following code: |
34. | Referencing Charts and Chart Objects in VBA Code |
35. | Specify Exact Location |