# vbaObjSet
{: .no_toc }

Assigns a raw object pointer to an **Object** variable, taking ownership of the existing reference without addrefing.

Syntax: **vbaObjSet(** *DstObject* **,** *SrcObjPtr* **)** **As LongPtr**

*DstObject*
: *required* **IUnknown**. The variable to receive the pointer. Any prior reference is released.

*SrcObjPtr*
: *required* **LongPtr**. The pointer to the COM object that *DstObject* should refer to. The pointer's existing reference count is **not** incremented.

This is the move-without-addref primitive --- used to wrap a freshly-handed-out raw pointer (from a Win32 `IUnknown**` out-parameter, for example) into an **Object** variable without leaking a reference.

The return value mirrors the assigned pointer.

### Common Errors

| Error | When |
|---|---|
| [94 (`&H5E`)](/Reference/Run-time-Errors.md#94), *Invalid use of Null* | *SrcObjPtr* is **Null** |

### See Also

- [vbaObjSetAddref](/tB/Modules/HiddenModule/vbaObjSetAddref.md) function -- copy-with-addref counterpart
- [vbaObjAddref](/tB/Modules/HiddenModule/vbaObjAddref.md) procedure
- [ObjPtr](/tB/Modules/Information/ObjPtr.md) function
