reading Data from Shapes?

S

Steve

I have a chart ("Len Jns") with what I think is a shape with some statistics
in a list(generated by an add in program).
Statistics
Cp=2.31
Cpk= 2.17
Cpu= 2.44 (0%)
Cpl= 2.17 (0%)
Est. Sigma= 0.2168557692295
Pp=1.28
Ppk= 1.2
Ppu= 1.35 (0%)
Ppl= 1.2 (0.02%)
Sigma= 0.391015203995593
Average=-0.088711611594405
Min=-1.18851392383101
Max=1.12866817155756
Count=69
No. Out of Spec=0 (0%)
Kurtosis=2.7
Skewness=0.69
I would like to be able to read this list an copy some of the data to
another worksheet.
Started with the following code which selects the correct object, which has
about 18 lines of statistical data. I need to read some of the data in the
middle of the list, such as the line with the Ppk data. I have tried Comments
etc with no luck. Any help would be greatly appreciated.

Sheets("Len Jns").Select
ActiveChart.Shapes("ds").Select
 
J

Joel

I don't have enough info to help. what i recommend is to Turn on Macro
Record and try to manually copy the data from the chart. Then post the code
so we can see what type of shape obeject you really have.
 
S

Steve

I have tried that and get the following code
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("Len Jns").Select
ActiveChart.Shapes("ds").Select
Selection.Characters.Text = _
"Statistics" & Chr(10) & "Cp=2.31" & Chr(10) & "Cpk= 2.17" & Chr(10)
& "Cpu= 2.44 (0%)" & Chr(10) & "Cpl= 2.17 (0%)" & Chr(10) & "Est. Sigma=
0.2168557692295" & Chr(10) & "Pp=1.28" & Chr(10) & "Ppk= 1.2" & Chr(10) &
"Ppu= 1.35 (0%)" & Chr(10) & "Ppl= 1.2 (0.02%)" & Chr(10) & "Sigma=
0.391015203995593" & Chr(10) & "Average=-0.088711611594405" & Chr(10) &
"Min=-1.18851"
Selection.Characters(201).Insert String:= _
"392383101" & Chr(10) & "Max=1.12866817155756" & Chr(10) &
"Count=69" & Chr(10) & "No. Out of Spec=0 (0%)" & Chr(10) & "Kurtosis=2.7" &
Chr(10) & "Skewness=0.69" & Chr(10) & ""
Selection.AutoScaleFont = False
With Selection.Characters(Start:=1, Length:=10).Font
.Name = "Arial Narrow"
.FontStyle = "Bold"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Selection.AutoScaleFont = False
With Selection.Characters(Start:=11, Length:=280).Font
.Name = "Arial Narrow"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Sheets("Data JNS").Select
Range("K2").Select
ActiveSheet.Paste

The problem I have is the values in the selection will change as the chart
is updated and I want to be able to read the current values
 
J

Joel

I think this will work

with Sheets("Len Jns")
ChartText = .ActiveChart.Shapes("ds").Characters.Text
end with
 
J

Joel

It looks like the chart was already acivated won the worksheet in your
original code. I added code to get the chart activated. Once you find the
real chanrt name from the code before modify as necessary.

Sub test()
For Each chrt In ActiveSheet.ChartObjects
MsgBox ("Chart Name : " & chrt.Name)
chrtname = chrt.Name
Next chrt
With Sheets("Len Jns")
Set a = Sheets("Len Jns")
.ChartObjects(chrtname).Activate
ChartText = .ActiveChart.Shapes("ds").Characters.Text
End With

End Sub
 
Top