Thread: Set Errors
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ray Pixley[_2_] Ray Pixley[_2_] is offline
external usenet poster
 
Posts: 5
Default Set Errors

I keep getting run time error 91, "object variable with block variable not
set" when doing the following:

First, create a Class Module called "CPM" whose content is

Option Explicit
Public Name as Collection

The code I'm trying to run is:

Option Explicit
Dim D As Collection
Dim C As CPM
Sub test()
Set C = New CPM
Set D = New Collection
D.Add "aa", "1"
subB
C.Name.Add "ss", "1" ' <----------------run time error
subA
End Sub
Sub subA()
C.Name.Add "tt", "2" ' <-------------- also want this to work
End Sub
Sub subB()
D.Add "bb", "3"
End Sub

I can add data to D object, but the C object constantly reports that run
time error. But the message makes no sense.

(My intent is to add a lot more public collections to CPM, and minimize the
amount of redundant coding that I have to do.)