put your code into the "this document" open sub

if need be put a loop to detect when whatever you are waiting for has finished, then protect

pete