This bug hits all 64-Bit VBA versions I'm aware of. Tested on Office 2013, 2016 and Office 365. Steps to reproduce:
Create a class module "SomeClass":
' this needs to be here to trigger the bug:
Private Sub Class_Terminate()
End Sub
Create a module:
Function ReturnFalse(o As Object) As Boolean
ReturnFalse = False
End Function
Sub test()
Debug.Print ReturnFalse(New SomeClass)
If ReturnFalse(New SomeClass) Then
Debug.Print "True"
Else
Debug.Print "False"
End If
End Sub
Now, invoking "test" will print
False
False
on 32-bit VBA hosts, but:
False
True
on 64-Bit VBA hosts.
There is also a topic on stackoverflow on this bug, with further informations:
Quote from the SO post: "I've tracked the bug down to this minimal example. Apparently, the problem seems to be, that using a temporary object (new SomeClass
here) breaks the evaluation of the IF
condition somehow, making it appear that the value of the condition is True
not matter what."
The bug is reproducible on Access and Excel and probably every other product hosting a 64-bit VBA7 environment.
Discussion is needed on how to bring this bug to attention to the right people, because there does not seem to be a canonical way for users to report bugs of the VBA runtime.