Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Jeff M
 
Posts: n/a
Default 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   Report Post  
John Mansfield
 
Posts: n/a
Default

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   Report Post  
Tushar Mehta
 
Posts: n/a
Default

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   Report Post  
Jon Peltier
 
Posts: n/a
Default

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   Report Post  
Jeff M
 
Posts: n/a
Default

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   Report Post  
Posted to microsoft.public.excel.charting
tom tom is offline
external usenet poster
 
Posts: 570
Default 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   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 6,582
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA: Where to find Excel Object model? N. Foldager Excel Discussion (Misc queries) 13 February 6th 05 06:43 PM
Chart Wizard "as object in:" turned off nedrgr21 Excel Discussion (Misc queries) 2 January 26th 05 06:35 AM
Problem with xlusrgal.xls file Alfred S C Lee Charts and Charting in Excel 2 December 29th 04 05:54 PM
pivot table multi line chart souris Charts and Charting in Excel 2 December 7th 04 03:56 AM
Can't save chart as object in current sheet Ann Scharpf Charts and Charting in Excel 1 December 3rd 04 11:24 PM


All times are GMT +1. The time now is 05:53 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"