Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Returning the name of an embedded chart?

I have a number of tables in a worksheet and need to generate a standard
graph beside each one. I can generate the graphs OK but my problem is by
default they always appear in the middle of the current view and are the
wrong size.

My ideal solution would be to be able to control where the chart first
appears, and what its dimensions are, when it is created. Is there anyway to
do this?
(I'm currently using
Charts.Add
ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1"
in order to create the chart.)

At the moment, I am resizing each chart using the Shapes method, but first I
have to find out the name:

Dim ref As Variant
ref = Right(ActiveChart.Name, Len(ActiveChart.Name) - Len(ActiveSheet.Name &
" "))
ActiveSheet.Shapes(ref).ScaleHeight 0.6, msoFalse
ActiveSheet.Shapes(ref).ScaleWidth 1.2, msoFalse

The definition of "ref" is rather forced since ActiveChart.Name returns a
string such as "Sheet1 Chart 215" not the "Chart 215" bit, which is what
Shapes needs. I can't believe there isn't a more efficient way to do this.
Any suggestions?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Returning the name of an embedded chart?


I've always believed that MS set up chart nomenclature to weed out the
faint of heart. <g
What you have been adding to the workbook is a chart sheet. (chart).
The Location method was then moving it to sheet1 where it became an
embedded chart. An embedded chart is contained in a ChartObject.
The ChartObject has the size and location properties.
The chart inside the ChartObject is what you access to change most of the
other properties.
Using object references eliminates the need to know the chart name...

Sub ChartMe()
Dim chtTable As Excel.Chart
Dim chtHolder As Excel.ChartObject '(the container)

With Worksheets("Sheet1")
'top, left,width,height
Set chtHolder = .ChartObjects.Add(.Range("B2").Left, .Range("B2").Top, 250, 125)

'Establish reference to the Chart in the ChartObject.
Set chtTable = chtHolder.Chart

'Use the ChartWizard property to customize the chart - see help for other options.
chtTable.ChartWizard Source:=.Range("G2:H10"), Gallery:=xlXYScatter
End With

'repeat above for each chart needed

Set chtTable = Nothing
Set chtHolder = Nothing
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware




"anthonyg"
wrote in message
I have a number of tables in a worksheet and need to generate a standard
graph beside each one. I can generate the graphs OK but my problem is by
default they always appear in the middle of the current view and are the
wrong size.

My ideal solution would be to be able to control where the chart first
appears, and what its dimensions are, when it is created. Is there anyway to
do this?
(I'm currently using
Charts.Add
ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1"
in order to create the chart.)

At the moment, I am resizing each chart using the Shapes method, but first I
have to find out the name:
Dim ref As Variant
ref = Right(ActiveChart.Name, Len(ActiveChart.Name) - Len(ActiveSheet.Name & " "))
ActiveSheet.Shapes(ref).ScaleHeight 0.6, msoFalse
ActiveSheet.Shapes(ref).ScaleWidth 1.2, msoFalse
The definition of "ref" is rather forced since ActiveChart.Name returns a
string such as "Sheet1 Chart 215" not the "Chart 215" bit, which is what
Shapes needs. I can't believe there isn't a more efficient way to do this.
Any suggestions?
Thanks
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Returning the name of an embedded chart?

If it's an active chart, use ActiveChart.Parent.Name to get the name to
insert into Shapes(). Or directly change the dimensions of the
ActiveChart.Parent (the ChartObject Jim refers to):

ActiveChart.Parent.Height = 200
ActiveChart.Parent.Width = 300

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"anthonyg" wrote in message
...
I have a number of tables in a worksheet and need to generate a standard
graph beside each one. I can generate the graphs OK but my problem is by
default they always appear in the middle of the current view and are the
wrong size.

My ideal solution would be to be able to control where the chart first
appears, and what its dimensions are, when it is created. Is there anyway
to
do this?
(I'm currently using
Charts.Add
ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1"
in order to create the chart.)

At the moment, I am resizing each chart using the Shapes method, but first
I
have to find out the name:

Dim ref As Variant
ref = Right(ActiveChart.Name, Len(ActiveChart.Name) - Len(ActiveSheet.Name
&
" "))
ActiveSheet.Shapes(ref).ScaleHeight 0.6, msoFalse
ActiveSheet.Shapes(ref).ScaleWidth 1.2, msoFalse

The definition of "ref" is rather forced since ActiveChart.Name returns a
string such as "Sheet1 Chart 215" not the "Chart 215" bit, which is what
Shapes needs. I can't believe there isn't a more efficient way to do
this.
Any suggestions?

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
Name Embedded Chart Jen[_4_] Excel Worksheet Functions 1 June 27th 07 02:18 PM
Embedded Table in Chart scott Excel Discussion (Misc queries) 1 November 8th 06 09:27 PM
Embedded Chart Versus Chart - ShowDetail Issue [email protected] Charts and Charting in Excel 1 May 14th 06 04:11 PM
enabling chart events for an embedded chart Wazooli Excel Programming 2 January 26th 06 01:15 PM
what is the difference between embedded chart and chart-in-a-sheet dhruv Excel Programming 1 January 18th 06 03:35 PM


All times are GMT +1. The time now is 10:23 AM.

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

About Us

"It's about Microsoft Excel"