chartobjects.activate fails

  • Thread starter Thread starter Scooter
  • Start date Start date
S

Scooter

I have the following snipet in my code

Windows("abc.xls").Activate
Sheets("Profile").Select
ActiveSheet.ChartObjects(1).Activate

When I get to the 3rd line I get a "runtime error 1004". I have verified
that the sheet does contain a chart. I have used this in other workbooks
with no problem. What is wrong here?
 
Try replacing the index with chart name.

ActiveSheet.ChartObjects("ChartName").Activate

Jacob
 
Is the sheet (or chart) protected? Is it the active sheet? Is the chart on a
sheet that's grouped with another sheet, or in a workbook that is shared?

- Jon
 
The sheet is not protected. Yes the chart is on the active sheet. The sheet
is not part of a group or shared workbook. This is very strange to me since
I have used this code many times but for this one instance it does not work.
 
Could be a corrupted workbook, to use a trite excuse.

Do you realize that you don't need to do all the activating and selecting
just to modify something in the chart? If your next line of code is (for
example)

ActiveChart.HasTitle = True

you can achieve the same using

Workbooks("abc.xls").Worksheets("Profile").ChartObjects(1).Chart.HasTitle
= True

- Jon
 
Back
Top