B
Benn
hi,
I have about 118 charts in excel. I have also 118 macros
each one associated with a chart. I also have a macro
called "RunAllMacros" which have macro calls like this
eg.
Run "ThisWorkbook.ChartMacro0"
..
..
Run "ThisWorkbook.ChartMacro49"
..
..
Run "ThisWorkbook.ChartMacro118"
When I try to run the macro "RunAllMacros"
I get an error "1004 application defined or object define
error". I have read the article about this error, but
I am having trouble fixing it. This error only occurrs
after is has executed the 48th macro. Here is the article
link : http://support.microsoft.com/default.aspx?
scid=http://support.microsoft.com:80/support/kb/articles/q
178/5/10.asp&NoWebContent=1
I have provided the code to one of the 118 macros below,
they are all the same except for the actual chart name.
Can anyone offer some advise on how to fix this
Thanks in advance.
-------------------------------------------------
Sub ChartMacro49()
Dim Counter As Integer
Dim ModValue As Integer
Dim UseColor As Integer
'***SET
LABELS****************************************************
***************
ActiveSheet.ChartObjects("Chart 55").Activate
ActiveChart.SeriesCollection(1).Select
ActiveChart.ChartArea.Select
ActiveChart.ApplyDataLabels Type:=xlDataLabelsShowLabel,
LegendKey:=False, HasLeaderLines:=True
ActiveSheet.ChartObjects("Chart 55").Activate
ActiveChart.SeriesCollection(1).DataLabels.Select
With Selection
..HorizontalAlignment = xlCenter
..VerticalAlignment = xlCenter
..Position = xlLabelPositionInsideEnd
..Orientation = xlHorizontal
End With
'***SET
COLORS****************************************************
***************
ActiveSheet.ChartObjects("Chart 55").Activate
ActiveChart.SeriesCollection(1).Select
For Counter = 1 To ActiveChart.SeriesCollection
(1).Points.Count
ActiveChart.SeriesCollection(1).Points(Counter).Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Shadow = False
ModValue = Counter Mod 2
If (ModValue > 0) Then
UseColor = 35
Else
UseColor = 22
End If
With Selection.Interior
..ColorIndex = UseColor
..Pattern = xlSolid
End With
Next
'---------------------------------------------------------
-----------------------
'***SET BORDERS AND CHART
SIZE***************************************************
ActiveSheet.ChartObjects("Chart 55").Activate
ActiveChart.PlotArea.Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlNone
End With
Selection.Interior.ColorIndex = xlNone
Selection.Left = 14
Selection.Top = 1
Selection.Width = 95
Selection.Height = 95
ActiveChart.ChartArea.Select
With Selection.Border
.Weight = 1
.LineStyle = 0
End With
Selection.Interior.ColorIndex = xlNone
Sheets("Coverage Report").DrawingObjects("Chart
55").RoundedCorners = False
Sheets("Coverage Report").DrawingObjects("Chart
55").Shadow = False
ActiveWindow.Visible = False
'***SET FONT
SIZE******************************************************
**********
ActiveSheet.ChartObjects("Chart 55").Activate
ActiveChart.SeriesCollection(1).DataLabels.Select
Selection.AutoScaleFont = True
With Selection.Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 11
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
ActiveSheet.ChartObjects("Chart 55").Activate
ActiveChart.ChartArea.Select
ActiveChart.PlotArea.Select
Selection.Height = 73
Selection.Width = 73
Selection.Left = 25
Selection.Top = 23
End Sub
I have about 118 charts in excel. I have also 118 macros
each one associated with a chart. I also have a macro
called "RunAllMacros" which have macro calls like this
eg.
Run "ThisWorkbook.ChartMacro0"
..
..
Run "ThisWorkbook.ChartMacro49"
..
..
Run "ThisWorkbook.ChartMacro118"
When I try to run the macro "RunAllMacros"
I get an error "1004 application defined or object define
error". I have read the article about this error, but
I am having trouble fixing it. This error only occurrs
after is has executed the 48th macro. Here is the article
link : http://support.microsoft.com/default.aspx?
scid=http://support.microsoft.com:80/support/kb/articles/q
178/5/10.asp&NoWebContent=1
I have provided the code to one of the 118 macros below,
they are all the same except for the actual chart name.
Can anyone offer some advise on how to fix this
Thanks in advance.
-------------------------------------------------
Sub ChartMacro49()
Dim Counter As Integer
Dim ModValue As Integer
Dim UseColor As Integer
'***SET
LABELS****************************************************
***************
ActiveSheet.ChartObjects("Chart 55").Activate
ActiveChart.SeriesCollection(1).Select
ActiveChart.ChartArea.Select
ActiveChart.ApplyDataLabels Type:=xlDataLabelsShowLabel,
LegendKey:=False, HasLeaderLines:=True
ActiveSheet.ChartObjects("Chart 55").Activate
ActiveChart.SeriesCollection(1).DataLabels.Select
With Selection
..HorizontalAlignment = xlCenter
..VerticalAlignment = xlCenter
..Position = xlLabelPositionInsideEnd
..Orientation = xlHorizontal
End With
'***SET
COLORS****************************************************
***************
ActiveSheet.ChartObjects("Chart 55").Activate
ActiveChart.SeriesCollection(1).Select
For Counter = 1 To ActiveChart.SeriesCollection
(1).Points.Count
ActiveChart.SeriesCollection(1).Points(Counter).Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Shadow = False
ModValue = Counter Mod 2
If (ModValue > 0) Then
UseColor = 35
Else
UseColor = 22
End If
With Selection.Interior
..ColorIndex = UseColor
..Pattern = xlSolid
End With
Next
'---------------------------------------------------------
-----------------------
'***SET BORDERS AND CHART
SIZE***************************************************
ActiveSheet.ChartObjects("Chart 55").Activate
ActiveChart.PlotArea.Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlNone
End With
Selection.Interior.ColorIndex = xlNone
Selection.Left = 14
Selection.Top = 1
Selection.Width = 95
Selection.Height = 95
ActiveChart.ChartArea.Select
With Selection.Border
.Weight = 1
.LineStyle = 0
End With
Selection.Interior.ColorIndex = xlNone
Sheets("Coverage Report").DrawingObjects("Chart
55").RoundedCorners = False
Sheets("Coverage Report").DrawingObjects("Chart
55").Shadow = False
ActiveWindow.Visible = False
'***SET FONT
SIZE******************************************************
**********
ActiveSheet.ChartObjects("Chart 55").Activate
ActiveChart.SeriesCollection(1).DataLabels.Select
Selection.AutoScaleFont = True
With Selection.Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 11
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
ActiveSheet.ChartObjects("Chart 55").Activate
ActiveChart.ChartArea.Select
ActiveChart.PlotArea.Select
Selection.Height = 73
Selection.Width = 73
Selection.Left = 25
Selection.Top = 23
End Sub