View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tony Radice Tony Radice is offline
external usenet poster
 
Posts: 1
Default Run Time Error 13 in Excel Chart (XP)

Ladies and Gentlemen;
(From a relative newbie programmer) I am getting a Run Time Error 13
the first time I access a chart in an Excel sheet. I am including the
module that generated the sheet, with the line that trips the error
identified. The confusing thing is that when I run this macro the
second through "nth" time it works! Also, the chart IS added. Can
someone assist to help me eliminate this error? Thanks!!!

Sub ADV1()
' Date: 6/1/04
' Author: (Combination) Tony Radice
' Purpose: Individually generate graphs per request from German G.
Server performance
' Captured from Macros and modified.
' NOTE: The FIRST Graph Generated will always cause an error 13 - it
seems to be a bug in
' EXCEL - I currently do not have a solution!
'
stExtent = CStr(Sheets("Control").Range("B2").Value)
stStCol = "S"
stEnCol = "T"
stShName = "ADV1"
stChTitle = "Advancer 1"
'
Sheets("Data").Activate

stRn = stStCol + ":" + stStCol + "," + stEnCol + ":" + stEnCol
Range(stRn).Select
Range(stEnCol + "1").Activate
Charts.Add ' <<< Error Here <<<<<
ActiveChart.ChartType = xlLine
stRn = stStCol + "1:" + stEnCol + stExtent
ActiveChart.SetSourceData Source:=Sheets("Data").Range(stRn), PlotBy
_
:=xlColumns
ActiveChart.SeriesCollection(1).Name = "=""Immediate"""
ActiveChart.SeriesCollection(2).Name = "=""Delayed"""
ActiveChart.Location Whe=xlLocationAsNewSheet, Name:=stShName
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = stChTitle
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MinimumScale = CStr(Sheets("Control").Range("B5").Value)
.MaximumScale = CStr(Sheets("Control").Range("C5").Value)
.MinorUnit = CStr(Sheets("Control").Range("D5").Value)
.MajorUnit = CStr(Sheets("Control").Range("E5").Value)
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
ActiveChart.SeriesCollection(2).Select
With Selection.Border
.ColorIndex = 3
.Weight = xlThin
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = xlNone
.MarkerForegroundColorIndex = xlNone
.MarkerStyle = xlNone
.Smooth = False
.MarkerSize = 3
.Shadow = False
End With
ActiveChart.SeriesCollection(1).Select
With Selection.Border
.ColorIndex = 4
.Weight = xlThin
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = xlNone
.MarkerForegroundColorIndex = xlNone
.MarkerStyle = xlNone
.Smooth = False
.MarkerSize = 3
.Shadow = False
End With
ActiveChart.Deselect

Sheets("Data").Activate

End Sub

Tony Radice

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!