You need to share the dialog code as well.
The return value is used to verify that the user pressed OK to close the dialog, or something else, before moving on to other code. If they pressed Cancel if you might want to abort the code... But if you don't care about that then you don't really need it.
Sorry, here it is. It's also just a small modification of something directly from the API, which is why it still has the date bit in it.
Side Question: Out of curiosity, how would you abort if the user clicks cancel? I get the feeling that they don't cover it because it's something you're supposed to already know how to do, but...I don't. Would you just put whatever action you want to take into an if ( button == "Ok" ) type statement so that cancel does nothing?
The reference to the document is a property of the dialog, so you access it from inside it like this:
And if you want to access the number of pages, like this:
Regarding your other question:
The code that actually does the work needs to be located outside the dialog object. You then use the return value of the dialog to check what the user clicked on. If they clicked on "ok" you continue. If not then you don't do anything.
That's it; it works now! Thank you very much for the help!