Hi Andy,
I tried recording macros and when I changed the constants like Chart1 and
Chart 1 to variables I started getting errors.
And I could check that the Names (Chart1 and Chart 1) were correct (after
considerable difficulty) and also the variables which were holding these
values were correct and hence couldnt understand what I was doing wrong.
Also the problem could have been because Im not conversant with object level
model for charts (im going through them presently but).
Some queries: -
a) Names of Charts are so difficult to find when im in a WORKSHEET. If I
click on the chart border and see the name box it would display "Chart area"
or if I click inside it would say plot area but not the name of the chart.
Rather I would have to extend the black borders of the chart area and see
the chart name displayed. Is there a better way than resorting to such
distortion.
b) Morever Im not able to see the names of the charts (mentioned in point a)
above) when they are embedded in the CHARTSHETTS. I have to take the trouble
of moving them to worksheets and stretching them and looking their names.
The same stretching within chartsheets doesnt yield names when am within
chartsheets. And yes, in case of Parent charts One cannnot do any
stretching?
c) Morever this is something I learned from my colleague just now. A Normal
data worksheet can have many charts and None of them is tethered to one
another. I thought that in the same way the charts within a Chartsheet are
also not "linked" to each other. BUT, I see that if I have a chart sheet
with a single chart in it then it is the "Parent chart" while any other
charts that we add subsequently in that chart sheet have their chartarea
within the chart area of the parent chart. Please throw some light on the
same.
d) When I tried moving the parent chart's location I got a message "To move
a chart from its own sheet to an object, you must first remove all chart
objects embedded in the sheet". On the other hand if I move the "child"
chart from this same chart sheet to another worksheet/new chartsheet one can
do flawlessly. So is the original chart in the chart sheet owner of that
chartsheet?
e) How do I refer to a parent chart in a chart sheet if i dont know its
name?
f) Suppose I have one embedded chart within a Chartsheet along with a parent
sheet then do I use chartobject method to refer to the child chart. Recorded
Macro tells me that it is so (please see the code
"ParentAndChildInChartSheet" below) On the other hand Help File for
ChartObject Object says that it "Represents an embedded chart on a
worksheet."
So why does recorded macro refer to the child with respect to chart objects
while help file says that Chartobject object is only for Embedded
WORKSHEETS?
sub ParentAndChildInChartSheet()
Sheets("Chart3").Select
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.Axes(xlValue).Select
Selection.TickLabels.AutoScaleFont = False
ActiveWindow.Visible = False
Windows("Book1").Activate
ActiveChart.Axes(xlValue).Select
Selection.TickLabels.AutoScaleFont = False
ActiveChart.Deselect
End Sub
In the above charts are there in Book1 workbook and while recording macro Im
never switching workbooks so why does the macro use the
"Windows("Book1").Activate"
Also in this when there is only parent chart in a chart sheet and no more
charts are there in the chart sheet, I get the following code: -
Sub ParentOnlyInChartSheet()
Sheets("Chart3").Select
ActiveChart.Axes(xlValue).Select
Selection.TickLabels.AutoScaleFont = False
End Sub
So does that mean the parent chart is aleays referred to as active chart?
Thanks a lot,
Hari
India