What does the keyword Set actually do in VBA?
In your case, it will produce an error. :-)
Set
assigns an object reference. For all other assignments the (implicit, optional, and little-used) Let
statement is correct:
Set object = New SomeObject
Set object = FunctionReturningAnObjectRef(SomeArgument)
Let i = 0
Let i = FunctionReturningAValue(SomeArgument)
' or, more commonly '
i = 0
i = FunctionReturningAValue(SomeArgument)
set
is used to assign a reference to an object. The C equivalent would be
int i;
int* ref_i;
i = 4; // Assigning a value (in VBA: i = 4)
ref_i = &i; //assigning a reference (in VBA: set ref_i = i)
From MSDN:
Set Keyword: In VBA, the Set keyword is necessary to distinguish between assignment of an object and assignment of the default property of the object. Since default properties are not supported in Visual Basic .NET, the Set keyword is not needed and is no longer supported.
Set is used for setting object references, as opposed to assigning a value.