Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default 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
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
Problems returning Collection object McManCSU[_23_] Excel Programming 4 August 9th 05 07:02 PM
Collection Todd Huttenstine Excel Programming 4 December 17th 04 09:41 PM
Collection Class problems Flemming Dahl Excel Programming 4 February 11th 04 04:41 PM
2 Collection questions Stuart[_5_] Excel Programming 5 January 30th 04 04:50 PM
Is a Collection the best option? Stuart[_5_] Excel Programming 5 August 31st 03 09:51 PM


All times are GMT +1. The time now is 03:06 PM.

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"