The code below set w = Nil at IDE (and application) run time:
If Window(0) IsA wMain Then
w = wMain(Window(0))
At the time the code above is executed, the application front window IsA wMain.
But w is Nil.
I know it is not a reference, but that code works fine when running both Windows (XP - 8.1 - both 10).
PS: the code is in a MenuItem. Other windows can appears frontmost thus the test.