Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Collection Problems
I am trying to add objects to a collection. The objects are type PolyPoint
(class). I am getting an error in the StorePoint line that Object doesn't support this property or method. Sub PanelMaker() Dim areaNum As Long areaNum = Sheets("Chart Plot Data").Range("a" & Cells(Rows.Count, 1).End(xlUp).Row).End(xlUp).Row For sect = 1 To areaNum For Each Cell In Sheets("Charts").Range("A1:A" & Cells(Rows.Count, 1).End(xlUp).Row) Set newP = New PolyPoint With newP .PointKey = Cell.Row .x = Cell.Value .y = Cell.Offset(0, 1).Value End With StorePoint (newP) Next Next sect End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Collection Problems
Assuming that Storepoint is a collection that has already been intantialted
then the correct syntax would be StorePoint.Add NewP, newP.PointKey Assuming that you want PointKey to be the Key to reference the item in the collection. Since you did not post the colleection declaration line I can only assume that somewhere publicly you have declared Public StorePoint as Collection and in another module you have set Storepoint = New Collection You can use early binding but it is not recommended Public StorePoint as New Collection -- HTH... Jim Thomlinson "Cody" wrote: I am trying to add objects to a collection. The objects are type PolyPoint (class). I am getting an error in the StorePoint line that Object doesn't support this property or method. Sub PanelMaker() Dim areaNum As Long areaNum = Sheets("Chart Plot Data").Range("a" & Cells(Rows.Count, 1).End(xlUp).Row).End(xlUp).Row For sect = 1 To areaNum For Each Cell In Sheets("Charts").Range("A1:A" & Cells(Rows.Count, 1).End(xlUp).Row) Set newP = New PolyPoint With newP .PointKey = Cell.Row .x = Cell.Value .y = Cell.Offset(0, 1).Value End With StorePoint (newP) Next Next sect End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Collection Problems
StorePoint is a Sub in a Module and is written as follows:
Public polyClass As Collection Sub StorePoint(cPoint As PolyPoint) If polyClass Is Nothing Then Set polyClass = New Collection End If polyClass.Add cPoint End Sub "Jim Thomlinson" wrote: Assuming that Storepoint is a collection that has already been intantialted then the correct syntax would be StorePoint.Add NewP, newP.PointKey Assuming that you want PointKey to be the Key to reference the item in the collection. Since you did not post the colleection declaration line I can only assume that somewhere publicly you have declared Public StorePoint as Collection and in another module you have set Storepoint = New Collection You can use early binding but it is not recommended Public StorePoint as New Collection -- HTH... Jim Thomlinson "Cody" wrote: I am trying to add objects to a collection. The objects are type PolyPoint (class). I am getting an error in the StorePoint line that Object doesn't support this property or method. Sub PanelMaker() Dim areaNum As Long areaNum = Sheets("Chart Plot Data").Range("a" & Cells(Rows.Count, 1).End(xlUp).Row).End(xlUp).Row For sect = 1 To areaNum For Each Cell In Sheets("Charts").Range("A1:A" & Cells(Rows.Count, 1).End(xlUp).Row) Set newP = New PolyPoint With newP .PointKey = Cell.Row .x = Cell.Value .y = Cell.Offset(0, 1).Value End With StorePoint (newP) Next Next sect End Sub |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Collection Problems
Your collection needs to have a key. The first argument of the add function
is the object itself and the second argument is the key. Without a key (to the best of my knowledge) the add will bomb out. It this where the error ie bieng raised? polyClass.Add cPoint ??? -- HTH... Jim Thomlinson "Cody" wrote: StorePoint is a Sub in a Module and is written as follows: Public polyClass As Collection Sub StorePoint(cPoint As PolyPoint) If polyClass Is Nothing Then Set polyClass = New Collection End If polyClass.Add cPoint End Sub "Jim Thomlinson" wrote: Assuming that Storepoint is a collection that has already been intantialted then the correct syntax would be StorePoint.Add NewP, newP.PointKey Assuming that you want PointKey to be the Key to reference the item in the collection. Since you did not post the colleection declaration line I can only assume that somewhere publicly you have declared Public StorePoint as Collection and in another module you have set Storepoint = New Collection You can use early binding but it is not recommended Public StorePoint as New Collection -- HTH... Jim Thomlinson "Cody" wrote: I am trying to add objects to a collection. The objects are type PolyPoint (class). I am getting an error in the StorePoint line that Object doesn't support this property or method. Sub PanelMaker() Dim areaNum As Long areaNum = Sheets("Chart Plot Data").Range("a" & Cells(Rows.Count, 1).End(xlUp).Row).End(xlUp).Row For sect = 1 To areaNum For Each Cell In Sheets("Charts").Range("A1:A" & Cells(Rows.Count, 1).End(xlUp).Row) Set newP = New PolyPoint With newP .PointKey = Cell.Row .x = Cell.Value .y = Cell.Offset(0, 1).Value End With StorePoint (newP) Next Next sect End Sub |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Collection Problems
I tried passing the key also as shown. I still can't get my StorePoint line
to work. Sub StorePoint(cPoint As PolyPoint, cKey As Long) If polyClass Is Nothing Then Set polyClass = New Collection End If polyClass.Add cPoint, cKey End Sub "Jim Thomlinson" wrote: Your collection needs to have a key. The first argument of the add function is the object itself and the second argument is the key. Without a key (to the best of my knowledge) the add will bomb out. It this where the error ie bieng raised? polyClass.Add cPoint ??? -- HTH... Jim Thomlinson "Cody" wrote: StorePoint is a Sub in a Module and is written as follows: Public polyClass As Collection Sub StorePoint(cPoint As PolyPoint) If polyClass Is Nothing Then Set polyClass = New Collection End If polyClass.Add cPoint End Sub "Jim Thomlinson" wrote: Assuming that Storepoint is a collection that has already been intantialted then the correct syntax would be StorePoint.Add NewP, newP.PointKey Assuming that you want PointKey to be the Key to reference the item in the collection. Since you did not post the colleection declaration line I can only assume that somewhere publicly you have declared Public StorePoint as Collection and in another module you have set Storepoint = New Collection You can use early binding but it is not recommended Public StorePoint as New Collection -- HTH... Jim Thomlinson "Cody" wrote: I am trying to add objects to a collection. The objects are type PolyPoint (class). I am getting an error in the StorePoint line that Object doesn't support this property or method. Sub PanelMaker() Dim areaNum As Long areaNum = Sheets("Chart Plot Data").Range("a" & Cells(Rows.Count, 1).End(xlUp).Row).End(xlUp).Row For sect = 1 To areaNum For Each Cell In Sheets("Charts").Range("A1:A" & Cells(Rows.Count, 1).End(xlUp).Row) Set newP = New PolyPoint With newP .PointKey = Cell.Row .x = Cell.Value .y = Cell.Offset(0, 1).Value End With StorePoint (newP) Next Next sect End Sub |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Collection Problems
What line is crashing? Is it the Add or is it some other line... Just so we
are all on the same page you realize that the key must be unique. -- HTH... Jim Thomlinson "Cody" wrote: I tried passing the key also as shown. I still can't get my StorePoint line to work. Sub StorePoint(cPoint As PolyPoint, cKey As Long) If polyClass Is Nothing Then Set polyClass = New Collection End If polyClass.Add cPoint, cKey End Sub "Jim Thomlinson" wrote: Your collection needs to have a key. The first argument of the add function is the object itself and the second argument is the key. Without a key (to the best of my knowledge) the add will bomb out. It this where the error ie bieng raised? polyClass.Add cPoint ??? -- HTH... Jim Thomlinson "Cody" wrote: StorePoint is a Sub in a Module and is written as follows: Public polyClass As Collection Sub StorePoint(cPoint As PolyPoint) If polyClass Is Nothing Then Set polyClass = New Collection End If polyClass.Add cPoint End Sub "Jim Thomlinson" wrote: Assuming that Storepoint is a collection that has already been intantialted then the correct syntax would be StorePoint.Add NewP, newP.PointKey Assuming that you want PointKey to be the Key to reference the item in the collection. Since you did not post the colleection declaration line I can only assume that somewhere publicly you have declared Public StorePoint as Collection and in another module you have set Storepoint = New Collection You can use early binding but it is not recommended Public StorePoint as New Collection -- HTH... Jim Thomlinson "Cody" wrote: I am trying to add objects to a collection. The objects are type PolyPoint (class). I am getting an error in the StorePoint line that Object doesn't support this property or method. Sub PanelMaker() Dim areaNum As Long areaNum = Sheets("Chart Plot Data").Range("a" & Cells(Rows.Count, 1).End(xlUp).Row).End(xlUp).Row For sect = 1 To areaNum For Each Cell In Sheets("Charts").Range("A1:A" & Cells(Rows.Count, 1).End(xlUp).Row) Set newP = New PolyPoint With newP .PointKey = Cell.Row .x = Cell.Value .y = Cell.Offset(0, 1).Value End With StorePoint (newP) Next Next sect End Sub |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Collection Problems
the keyPass should be unique as it is sending the row number in a list of rows.
Call StorePoint(newP, keyPass) "Jim Thomlinson" wrote: What line is crashing? Is it the Add or is it some other line... Just so we are all on the same page you realize that the key must be unique. -- HTH... Jim Thomlinson "Cody" wrote: I tried passing the key also as shown. I still can't get my StorePoint line to work. Sub StorePoint(cPoint As PolyPoint, cKey As Long) If polyClass Is Nothing Then Set polyClass = New Collection End If polyClass.Add cPoint, cKey End Sub "Jim Thomlinson" wrote: Your collection needs to have a key. The first argument of the add function is the object itself and the second argument is the key. Without a key (to the best of my knowledge) the add will bomb out. It this where the error ie bieng raised? polyClass.Add cPoint ??? -- HTH... Jim Thomlinson "Cody" wrote: StorePoint is a Sub in a Module and is written as follows: Public polyClass As Collection Sub StorePoint(cPoint As PolyPoint) If polyClass Is Nothing Then Set polyClass = New Collection End If polyClass.Add cPoint End Sub "Jim Thomlinson" wrote: Assuming that Storepoint is a collection that has already been intantialted then the correct syntax would be StorePoint.Add NewP, newP.PointKey Assuming that you want PointKey to be the Key to reference the item in the collection. Since you did not post the colleection declaration line I can only assume that somewhere publicly you have declared Public StorePoint as Collection and in another module you have set Storepoint = New Collection You can use early binding but it is not recommended Public StorePoint as New Collection -- HTH... Jim Thomlinson "Cody" wrote: I am trying to add objects to a collection. The objects are type PolyPoint (class). I am getting an error in the StorePoint line that Object doesn't support this property or method. Sub PanelMaker() Dim areaNum As Long areaNum = Sheets("Chart Plot Data").Range("a" & Cells(Rows.Count, 1).End(xlUp).Row).End(xlUp).Row For sect = 1 To areaNum For Each Cell In Sheets("Charts").Range("A1:A" & Cells(Rows.Count, 1).End(xlUp).Row) Set newP = New PolyPoint With newP .PointKey = Cell.Row .x = Cell.Value .y = Cell.Offset(0, 1).Value End With StorePoint (newP) Next Next sect End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Problems returning Collection object | Excel Programming | |||
Collection | Excel Programming | |||
Collection Class problems | Excel Programming | |||
2 Collection questions | Excel Programming | |||
Is a Collection the best option? | Excel Programming |