A
Arne Hegefors
I have a syntax probelm. First I have a loop that checks to see if an object
in the selection is a chart. If that is so it passes the chart as an argument
to a sub that makes changes to that chart. The problem is that I do not
really know how to write the code.
The code looks like:
Sub arrayLoop()
Dim obj As Object
Dim myChart As Excel.Chart
For Each obj In Selection
If TypeName(obj) = "ChartObject" Then
Set myChart = obj
Call linjeDiagramKnapp(myChart)
End If
Next
end sub
Sub linjeDiagramKnapp(argChart As Excel.Chart)
Dim mySize As DoubleWith argChart
with argChart
..ApplyCustomType ChartType:=xlUserDefined, TypeName:="Standard"
With argChart
..Height = 150
..Width = 150
..Top = 100
..Left = 100
End With
With argChart.PlotArea
..Height = 100
..Width = 100
..Top = 10
..Left = 10
..Interior.ColorIndex = xlNone
End With
The problem is:
1) I get "incompatible types" at the line "Set myChart = obj".
2) Assuming that I fix problem 1) how shall I refer to the chart? Eg if I
want to change the plot area as in the last piece of code, is the current
syntax correct? If not how shall I write it?
Please, please help me out here! I know that I am a pain but I really cannot
solve it! Thank you so much for all your help! Any assistance always
appreciated!
in the selection is a chart. If that is so it passes the chart as an argument
to a sub that makes changes to that chart. The problem is that I do not
really know how to write the code.
The code looks like:
Sub arrayLoop()
Dim obj As Object
Dim myChart As Excel.Chart
For Each obj In Selection
If TypeName(obj) = "ChartObject" Then
Set myChart = obj
Call linjeDiagramKnapp(myChart)
End If
Next
end sub
Sub linjeDiagramKnapp(argChart As Excel.Chart)
Dim mySize As DoubleWith argChart
with argChart
..ApplyCustomType ChartType:=xlUserDefined, TypeName:="Standard"
With argChart
..Height = 150
..Width = 150
..Top = 100
..Left = 100
End With
With argChart.PlotArea
..Height = 100
..Width = 100
..Top = 10
..Left = 10
..Interior.ColorIndex = xlNone
End With
The problem is:
1) I get "incompatible types" at the line "Set myChart = obj".
2) Assuming that I fix problem 1) how shall I refer to the chart? Eg if I
want to change the plot area as in the last piece of code, is the current
syntax correct? If not how shall I write it?
Please, please help me out here! I know that I am a pain but I really cannot
solve it! Thank you so much for all your help! Any assistance always
appreciated!