RCW does not convert integer when passing from .Net to COM
See the question and my original answer on StackOverflowWhat's important is how the conversion is defined between the two worlds (unmanaged vs managed) in the native or managed code side.
If conversion is defined using a COM / Automation Type Library (in DLL or TLB for example), then it will be declared as the corresponding type automatically, especially for very well known types such as the unsigned 16-bit integer type.
So a VBA 16-bit type will be declared as the equivalent (if it's a standard well-known type) .NET 16-byte. For example, VBA integer
will be declared as .NET's Int16
(like the short
keyword in C#).
If conversion is defined manually, for example using .NET interface
with COM annotations, then it's the developer's task to ensure the declaration is consistent for both sides (or problems/bugs/crashes may happen).
I suggest two links in the official doc about this: Default Marshaling Behavior and Blittable and Non-Blittable Types to determine what can be considered as standard or well-known types.