I have a class module, named Normal, in VBA with the following code:
Private mLine As LineElement
Public Property Get Line() As LineElement
Line = mLine
End Property
Public Property Set Line(ByRef vLine As LineElement)
mLine = vLine
End Property
This class is used by the following code:
Sub Run
Dim Line As LineElement
Set Line = New LineElement
Dim Norm As Normal
Set Norm = New Normal
Set Norm.Line = Line 'FAILS here with "Object Variable or With Block Variable not set"'
End Sub
Also, if I change the code in the Normal class module to:
Private mLine As LineElement
Public Property Get Line() As LineElement
Line = mLine
End Property
Public Sub SetLine(ByRef vLine As LineElement) 'changed from property to sub'
mLine = vLine
End Property
and the failing line to
Norm.SetLine( Line )
I get an “Object does not support this property or method” error. What exactly am I doing wrong in both of these cases?
Try this: