Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Naming a chart object
This has got to be simple but I can't find it...
I'm using vba to create several charts as objects (as opposed to on their own page). I want to refer to them later, so I want to give them meaningful names - how do I name them something other than the default "Chart 1", "Chart 2" etc? Thanks! |
#2
|
|||
|
|||
Jeff,
To get the current name of the chart, activate it by clicking on it once and run this macro: Sub GetName() MsgBox "The chart name is: " & ActiveChart.Parent.Name End Sub To rename the chart, activate it and run this macro (substitute Chart2 with the name of your choice): Sub RenameChart() ActiveChart.Parent.Name = "Chart2" End Sub ---- Regards, John Mansfield http://www.pdbook.com "Jeff M" wrote: This has got to be simple but I can't find it... I'm using vba to create several charts as objects (as opposed to on their own page). I want to refer to them later, so I want to give them meaningful names - how do I name them something other than the default "Chart 1", "Chart 2" etc? Thanks! |
#3
|
|||
|
|||
First of all, for an embedded chart you are better off naming the
parent container, i.e., the chartobject, not the chart itself. Second, it depends on how you create them. If you modifed the code from the macro recorder, you would use something like: Sub Macro2() Dim x As Chart Set x = Charts.Add() With x .SetSourceData Source:=Sheets("Sheet1").Range("A1:A12") .ChartType = xlColumnClustered Set x = .Location(Whe=xlLocationAsObject, Name:="Sheet1") End With x.Parent.Name = "My Chart" MsgBox ActiveSheet.ChartObjects("my chart").Chart.Name End Sub -- Regards, Tushar Mehta www.tushar-mehta.com Excel, PowerPoint, and VBA add-ins, tutorials Custom MS Office productivity solutions In article , says... This has got to be simple but I can't find it... I'm using vba to create several charts as objects (as opposed to on their own page). I want to refer to them later, so I want to give them meaningful names - how do I name them something other than the default "Chart 1", "Chart 2" etc? Thanks! |
#4
|
|||
|
|||
Jeff -
I have a web page that describes the whole chart naming process: http://peltiertech.com/Excel/ChartsH...ameAChart.html - Jon ------- Jon Peltier, Microsoft Excel MVP Peltier Technical Services Tutorials and Custom Solutions http://PeltierTech.com/ _______ Jeff M wrote: This has got to be simple but I can't find it... I'm using vba to create several charts as objects (as opposed to on their own page). I want to refer to them later, so I want to give them meaningful names - how do I name them something other than the default "Chart 1", "Chart 2" etc? Thanks! |
#5
|
|||
|
|||
Thanks to all 3 of you for your help - all three posts were accurate and
helpful, though they each approached the problem from a different angle. Thanks - "Jeff M" wrote: This has got to be simple but I can't find it... I'm using vba to create several charts as objects (as opposed to on their own page). I want to refer to them later, so I want to give them meaningful names - how do I name them something other than the default "Chart 1", "Chart 2" etc? Thanks! |
#6
Posted to microsoft.public.excel.charting
|
|||
|
|||
Naming a chart object
Jon,
When I use the following code: ActiveChart.Parent.Name = "z" the VB editor automatically adds the autosave code: Application.Goto Reference:="PERSONAL.XLS!renamechart" Windows("PERSONAL.XLS").Activate ActiveWindow.WindowState = xlNormal How can I get it not to save each time I rename a chart "Jon Peltier" wrote: Jeff - I have a web page that describes the whole chart naming process: http://peltiertech.com/Excel/ChartsH...ameAChart.html - Jon ------- Jon Peltier, Microsoft Excel MVP Peltier Technical Services Tutorials and Custom Solutions http://PeltierTech.com/ _______ Jeff M wrote: This has got to be simple but I can't find it... I'm using vba to create several charts as objects (as opposed to on their own page). I want to refer to them later, so I want to give them meaningful names - how do I name them something other than the default "Chart 1", "Chart 2" etc? Thanks! |
#7
Posted to microsoft.public.excel.charting
|
|||
|
|||
Naming a chart object
I have no idea where that other code comes from. It doesn't look like any
autosave routine to me. - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions Peltier Technical Services, Inc. - http://PeltierTech.com _______ "Tom" wrote in message ... Jon, When I use the following code: ActiveChart.Parent.Name = "z" the VB editor automatically adds the autosave code: Application.Goto Reference:="PERSONAL.XLS!renamechart" Windows("PERSONAL.XLS").Activate ActiveWindow.WindowState = xlNormal How can I get it not to save each time I rename a chart "Jon Peltier" wrote: Jeff - I have a web page that describes the whole chart naming process: http://peltiertech.com/Excel/ChartsH...ameAChart.html - Jon ------- Jon Peltier, Microsoft Excel MVP Peltier Technical Services Tutorials and Custom Solutions http://PeltierTech.com/ _______ Jeff M wrote: This has got to be simple but I can't find it... I'm using vba to create several charts as objects (as opposed to on their own page). I want to refer to them later, so I want to give them meaningful names - how do I name them something other than the default "Chart 1", "Chart 2" etc? Thanks! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
VBA: Where to find Excel Object model? | Excel Discussion (Misc queries) | |||
Chart Wizard "as object in:" turned off | Excel Discussion (Misc queries) | |||
Problem with xlusrgal.xls file | Charts and Charting in Excel | |||
pivot table multi line chart | Charts and Charting in Excel | |||
Can't save chart as object in current sheet | Charts and Charting in Excel |