Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run Time Error 13 in Excel Chart (XP)
Tony -
I ran through the code several times, and it never died on the Charts.Add step. Do you have the latest service release for your version of Excel? I do have a few other suggestions. * Use & for text concatenation, not + * These lines are unneeded: Sheets("Data").Activate stRn = stStCol + ":" + stStCol + "," + stEnCol + ":" + stEnCol Range(stRn).Select Range(stEnCol + "1").Activate * Replace the first line below with the second: ActiveChart.Location Whe=xlLocationAsNewSheet, Name:=stShName ActiveChart.Name = stShName - Jon ------- Jon Peltier, Microsoft Excel MVP Peltier Technical Services Tutorials and Custom Solutions http://PeltierTech.com/ _______ Tony Radice wrote: 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! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Dynamic chart generation: Run time Error '1004: Method 'Cells' of object'_Global' fai | Charts and Charting in Excel | |||
Excel VB Run-time error '50290' | Excel Worksheet Functions | |||
Run-time Error in Excel? | Excel Worksheet Functions | |||
EXCEL VBA - Run-time Error 1004 | Excel Programming | |||
EXCEL VBA - Run-time Error 1004 | Excel Programming |