View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.charting
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Bug with Chart.Name?

Could you explain what you mean by "exported". With the chart Export method
you need to supply a file name for what will be an image of the chart saved
to disc (unique to avoid over writing). This name is not related to the
chart name, even though in practice you might use a similar name, eg
"C:\ChartSales01.gif"

Do you mean perhaps copying to some other workbook. Either way, there can be
problems referencing all chartobjects under relatively rare scenarios (or
any objects at the drawing object level). The following may reference
different charts,

for each chtObj in ws.chartobjects
vs
for i = 1 to ws.ChartObjects.Count
Set chtObj = ws.Chartobjects(i)

(ws is a reference to the sheet)

One way discrepancies can arise is after first renaming, then grouping, then
copying then ungrouping. You can end up with multiple chartobjects having
the same 'new name'.

Normally the For Next loop is more reliable (same as Chartobjects.count) but
the For Each loop will pick up any chartobjects that are still in a group
(but can be problematic for different reasons).

Regards,
Peter T



"bart13" wrote in message
...

Excel 2003 with hundreds of charts in 3 tabs and just under 200 total
tabs. I'm trying to automate the export of them with a macro. The code
seems fine, but all the charts are not being exported.

I've changed the chart names away from the default Chart ### via the
shift click method but even though the name shows correctly in the name
box at the upper left, a few are still named Chart ### when exported.

I've even tried copying a few of the charts to a brand new chart tab -
no joy. There are six charts (and that's what
ActiveSheet.ChartObjects.Count shows) in the new tab but only three
will export. The other three that will not export were created via
ctrl-c copies of one of the working ones and then changes were made
through the normal UI to the date range, Chart.Name, etc.

Maybe some kind of weird corruption in the various problem charts or
some unknown limit to Chart.Name... or just plain PEBKAC?




--
bart13