You no longer need to use the Sleep(xx) in the While IsMoving. That was changed many years ago.
All you normally need to wait for movement to end is:
While IsMoving()
Wend
However, when homing, you shouldn't even need the While IsMoving. Try just using the
DoOEMButtin(1023) by itself, and see if you have any issues. The macro should wait until homing is complete before it continues. If you find that it doesn't, then try:
DoOEMButton(1023)
While IsMoving()
Wend