F
fredrik.kjell
Hi,
I have the following setup:
1. Class module "ChartHandler"
2. Module "Tester"
In ChartHandler, I have a function to return an instance of a
ChartObject. The chart is present in a worksheet in my workbook. I
successfully claim the chart with the following code:
Public Function claimChartObject(ByVal s As String) as ChartObject
Debug.Print ws.Name ' prints worksheet name correctly
Debug.Print ws.ChartObjects(s).Name ' prints the name correctly
claimChartObject = ws.ChartObjects(s)
End Function
The above function works as it should. However, when I try to get the
chartobject from my module, it fails. The code in my module is
something like this:
Dim coChart As ChartObject
Dim handler As ChartHandler ' Creates an instance of ChartHandler -
works
' Some initialization...
' ....
Set coChart = handler.claimChartObject("myChart") ' <-- this fails!
If I try to snatch the chartobject with the following line, it works:
Set coChart = Worksheets("chart").ChartObjects("myChart")
So my question is, how to I return the chartobject from the class?? I
tried changing "Public Function" to "Property Get" but without success.
Any help much appreciated!
Fredrik
I have the following setup:
1. Class module "ChartHandler"
2. Module "Tester"
In ChartHandler, I have a function to return an instance of a
ChartObject. The chart is present in a worksheet in my workbook. I
successfully claim the chart with the following code:
Public Function claimChartObject(ByVal s As String) as ChartObject
Debug.Print ws.Name ' prints worksheet name correctly
Debug.Print ws.ChartObjects(s).Name ' prints the name correctly
claimChartObject = ws.ChartObjects(s)
End Function
The above function works as it should. However, when I try to get the
chartobject from my module, it fails. The code in my module is
something like this:
Dim coChart As ChartObject
Dim handler As ChartHandler ' Creates an instance of ChartHandler -
works
' Some initialization...
' ....
Set coChart = handler.claimChartObject("myChart") ' <-- this fails!
If I try to snatch the chartobject with the following line, it works:
Set coChart = Worksheets("chart").ChartObjects("myChart")
So my question is, how to I return the chartobject from the class?? I
tried changing "Public Function" to "Property Get" but without success.
Any help much appreciated!
Fredrik