mantooth29
01-01-2013, 11:02 AM
Hello,
I am trying to simplify the client code for my classes, and am wondering if I can set properties of objects like this...
With myClass
.SourceWorkbook = ThisWorkbook
End With
as opposed to this
Set myClass.Sourceworkbook = ThisWorkbook
The corresponding Properties in the class module look like this
Dim pSourceWorkbook as Excel.Workbook
Property Get SourceWorkbook() as Excel.Workbook
Set SourceWorkbook = pSourceWorkbook
End Property
Property Set SourceWorkbook(ByRef Value as Excel.Workbook)
Set pSourceWorkbook =Value
End Property
Is this possible? When attempting as I have written, I get the usual "Object Variable or With Block Variable not set" error.
I am trying to simplify the client code for my classes, and am wondering if I can set properties of objects like this...
With myClass
.SourceWorkbook = ThisWorkbook
End With
as opposed to this
Set myClass.Sourceworkbook = ThisWorkbook
The corresponding Properties in the class module look like this
Dim pSourceWorkbook as Excel.Workbook
Property Get SourceWorkbook() as Excel.Workbook
Set SourceWorkbook = pSourceWorkbook
End Property
Property Set SourceWorkbook(ByRef Value as Excel.Workbook)
Set pSourceWorkbook =Value
End Property
Is this possible? When attempting as I have written, I get the usual "Object Variable or With Block Variable not set" error.