Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default 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
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
Dynamic chart generation: Run time Error '1004: Method 'Cells' of object'_Global' fai Ajay_N Charts and Charting in Excel 1 August 15th 06 03:54 AM
Excel VB Run-time error '50290' Bruce Blackman Excel Worksheet Functions 0 May 5th 05 02:26 PM
Run-time Error in Excel? Elena Excel Worksheet Functions 0 April 20th 05 04:26 PM
EXCEL VBA - Run-time Error 1004 sakieboy Excel Programming 5 January 30th 04 03:47 PM
EXCEL VBA - Run-time Error 1004 sakieboy[_3_] Excel Programming 0 January 29th 04 02:27 PM


All times are GMT +1. The time now is 03:21 AM.

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

About Us

"It's about Microsoft Excel"