Question

Q: Excel 16.13 for Mac User Defined Class passed as parameter all properties are Null

Build 424: Properties all return Null but Methods work.

Test:

Option Explicit

Sub testUDC()
Dim oTest As clsTest
Set oTest = New clsTest
oTest.Name = "Fred"
oTest.Var = 1
Debug.Print oTest.Name, oTest.Var, oTest.Value()    ' Fred       1    1
oTest.Value = 2
Debug.Print oTest.Name, oTest.Var, oTest.Value()    ' Fred       2    2
printTest oTest
End Sub

Sub printTest(obj As Object)
Debug.Print IsObject(obj), TypeName(obj), (obj Is Nothing) ' True  clsTest    False
Debug.Print obj.Name, obj.Var, obj.Value()
'Excel 2016 Win (16.0 build 9126) : Fred      2     2
'Excel 2016 Mac (16.13 build 424) : Null      Null  2
End Sub

Class:

'clsTest
Option Explicit

Public Name As String
Public Var As Variant
Public obj As Object

Public Property Get Value()
Value = Var
End Property

Public Property Let Value(varValue As Variant)
Var = varValue
End Property



Can you provide some more context into what you are trying to do and when exactly this is occurring? The more detail you can provide the better.

-Jesse

Did this solve your problem?

Sorry this didn't help.

2 people were helped by this reply


I want to use a user defined object for key/value pairs. I found the above bug while testing it.

The code above is the smallest illustration  of the bug.

Debug.print oTest.properties are correct. 

Pass oTest to a sub printTest and the properties are null in the Mac but the methods still work. In Windows the passed object preserves the properties the same , as expected. 

Try this code yourself.

So, what MSFT need to do is make the Mac version work , as the Windows version does.

Did this solve your problem?

Sorry this didn't help.

2 people were helped by this reply


I've passed this issue along to the Excel Mac team and will let you know once I hear anything back.

-Jesse 

Did this solve your problem?

Sorry this didn't help.

2 people were helped by this reply


Demo

Here are two workbooks: one shows Null in a passed userdefined object property, one does not. 

Excel 16.14 180429

https://www.dropbox.com/s/j6oh9eqexj6nj2r/MacIsNull.xlsm?dl=0

https://www.dropbox.com/s/0ln3fwy4g643tip/MacNotNull.xlsm?dl=0

It's the same code. Just open them, read the code, and click the test button for the msgbox or run the test proc directly with F5.

What can the difference be?

Did this solve your problem?

Sorry this didn't help.


Thanks for the sample workbooks. I have passed this along to the team investigating.

-Jesse

Did this solve your problem?

Sorry this didn't help.


Jesse, I just saw the difference. It's a simple bug for the team.


This fails, passing a user-defined Class1 object, the received object's properties are Null
Sub test(obj as Object)

This works, the properties are retained:
Sub test(obj as Class1)

Did this solve your problem?

Sorry this didn't help.


 
Question Info

Views: 46 Last updated: May 17, 2018 Applies to: