I've tested my code and it works perfectly, if the dialog isn't open, then open it,else just make it the active window (and sparta's code should works too)