getting the active chart/chartobject's name
  Home FAQ Contact Sign in
microsoft.public.excel.programming only
 
Advanced search
POPULAR GROUPS

more...

microsoft ... programming Profile…
 Up
getting the active chart/chartobject's name         


Author: Stanley
Date: Dec 21, 2007 11:26

Given the code below, does anyone have any suggestions on how to
obtain the active chart/chartobject's name so that I can address
Shape(name) properly when I try ot move the shape?

[code]
Sub LT(wbname As String, wsname As String) ' Graphing Lifetime
Results
Dim normalgraph As Chart ' normal graph variable
Dim regressgraph As Chart ' regression graph
variable
Dim twoGraphs As ChartObjects 'Chartobjects for
embedded charts

Dim ngName As String 'normal graph name for moving
the chart
Dim rgName As String 'regression graph name for
moving the chart

Dim i As Long ' loop counter
Dim colEnd As Long ' end of a column

Workbooks(wbname).Sheets(wsname).Activate 'activate
worksheet of interest
Show full article (1.27Kb)
4 Comments
Re: getting the active chart/chartobject's name         


Author: brittonsm
Date: Dec 21, 2007 11:36

How about this?

With .ActiveWorkbook
.Sheets("Sheet1").Select
.ActiveSheet.ChartObjects("Chart 1").Activate
.ActiveChart.ChartArea.Copy
End With

On Dec 21, 11:26 am, Stanley gmail.com> wrote:
> Given the code below, does anyone have any suggestions on how to
> obtain the active chart/chartobject's name so that I can address
> Shape...
Show full article (1.68Kb)
no comments
Re: getting the active chart/chartobject's name         


Author: Stanley
Date: Dec 21, 2007 12:16

On Dec 21, 11:36 am, brittonsm gmail.com> wrote:
> How about this?
>
> With .ActiveWorkbook
> .Sheets("Sheet1").Select
> .ActiveSheet.ChartObjects("Chart 1").Activate
> .ActiveChart.ChartArea.Copy
> End With
>
> On Dec 21, 11:26 am, Stanley gmail.com> wrote:
>
>> Given the code below, does anyone have any suggestions on how to
>> obtain the active chart/chartobject's name so that I can address
>> Shape(name) properly when I try ot move the shape?
>
>> [code]
>> Sub LT(wbname As String, wsname As String) ' Graphing Lifetime
>> Results
>> Dim normalgraph As Chart ' normal graph variable
>> Dim regressgraph As Chart ' regression graph ...
Show full article (1.83Kb)
no comments
Re: getting the active chart/chartobject's name         


Date: Dec 22, 2007 02:07

after this line
> ngName = normalgraph.Name
add
sChtObjName = normalgraph.Parent.Name

If all you want to do is move it with in the same routine as you created it,
simply

With normalgraph.Parent
.Left = 10
.Top = 20
' .width & .height if necessary
End With

However, no need to first add a chart sheet, add the chartobject to the
requisite sheet, sized to suit, eg

Sub test2()
Dim chtObj As ChartObject
Dim cht As Chart
Dim cell As Range

Set cell = ActiveSheet.Range("B3")
Show full article (2.14Kb)
no comments
Re: getting the active chart/chartobject's name         


Author: Andy Pope
Date: Dec 22, 2007 02:13

Hi,

Try this code,

'----------
Set normalgraph = Charts.Add
Set normalgraph = _
normalgraph.Location(where:=xlLocationAsObject, Name:=wsname)

With Worksheets(wsname)
Set normalgraph = .ChartObjects(.ChartObjects.Count).Chart
End With
ngName = normalgraph.Parent.Name
'----------

Cheers
Andy

Stanley wrote:
> Given the code below, does anyone have any suggestions on how to
> obtain the active chart/chartobject's name so that I can address
> Shape(name) properly when I try ot move the shape...
Show full article (1.70Kb)
no comments