PDA

View Full Version : Solved: Determining Whether User Selects Cancel



jasoncw
12-04-2007, 07:24 AM
I have a procedure that requires the file to be saved prior to continuing. If the file is not saved, I prompt the user to save the file:
If ActiveDocument.Path = vbNullString Then _
Application.Dialogs(wdDialogFileSaveAs).Show

Is there a way to determine whether the user selects Cancel, or should I simply loop through this procedure until a path is detected? I'm open to any better suggestions as well.

TIA

Jason

TonyJollans
12-04-2007, 09:30 AM
When you say the document must be saved, I presume you want all changes to it saved even if it has already been saved sometime but further changes to it have since been made.

This being the case, what you need to check is ActiveDocument.Saved - or you could just go ahead with the Save anyway, although that would depend on whether you wanted to save as a new document or not.

I think you should probably be a bit more polite with your users but this quick and dirty method will keep prompting them until they save ..


Do: Loop Until Application.Dialogs(wdDialogFileSaveAs).Show

jasoncw
12-04-2007, 09:36 AM
Hi, Tony. Thanks for the reply.

I don't necessarily need all changes to be saved; only for it to be initially saved. This procedure is in a template, and the procedure looks at all *.doc files in the current directory (the directory of the active document). So that is the only purpose of the save.

I agree that I should be more polite than to force a loop until it is saved, but it is only directed toward a small group, and I'm sure they won't mind. :)

Thanks again,

Jason