Greg
Thu Nov 22 09:29:28 PST 2007
Klaus,
That is one of the first things I tried. Problem is that event fires before
the Dialog appears.
--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
Klaus Linke wrote:
> There isn't a wdDialog constant for that dialog (and lots of other
> dialogs).
> BTW, the control ID is 752, so
> CommandBars.FindControl(Id:=752).Execute would do the same as
> Dialogs(98).Execute. Not that that helps you any ;-)
>
>
>> I don't want to disable the Escape key.
> When a dialog is open, hitting the Escape key does the same as
> clicking on the close "X".
> Setting EnableCancelKey to False just prevents the error 4198 if the
> user cancels out of the dialog.
>
> But that doesn't seem to be your main problem anyway.
>
> I've never seen a solution for intercepting when the user clicks the
> doc's close button. Usually, you'd simply write your own macro for
> the command (Sub FileExit() in this case), but that does not work
> (... at least in older versions).
>
> Maybe you could put whatever you want to do in the Sub
> Document_Close() event handler?
>
> Klaus
>
>
> "Greg Maxey" <gmaxey@mvps.oSCARrOMEOgOLF> wrote:
>> Klaus,
>>
>> Thanks for the reply:
>>
>> Sub Test1()
>> Dialogs(98).Show
>> End Sub
>> Shows the dialog that asked a user if they want to save an open
>> document if they click the "X" button or the File Close command.
>>
>> I would normally not use a number but a constant like:
>> Sub Test2()
>> Dialogs(wdDialogFileSaveAs).Show
>> End Sub
>>
>> I can't find a constant for the value 98. Yes:
>>
>> Sub Test3()
>> MsgBox Dialogs(98).CommandName
>> End Sub
>>
>> Returns "FileExit:
>>
>> But
>> Sub Test4()
>> Dialogs(wdDialogsFileExit).Show
>> End Sub
>>
>> Doesn't compile
>>
>>> You'd usually disable the Escape key before you show a dialog to
>>> avoid that error, and enable it later on
>>
>> I don't want to disable the Escape key.
>>
>> Here is what I am trying to do and why I need to know what the user
>> does when that dialog is displayed after the user presses the "X" or
>> selects File Close:
>>
>> I have written a macro that inserts a bookmark at the selection when
>> the use saves a document. To fire this macro I have intercepted the
>> FileSave, FileSaveAll, and FileSaveAs events.
>>
>> For example:
>> Sub FileSaveAs()
>> With Dialogs(wdDialogFileSaveAs)
>> If .Show = 0 Then Exit Sub
>> Selecting.QuickSaveMark 'This is a procedure in another module
>> that sets the bookmark
>> End With
>> End Sub
>>
>> This works fine if the user has an new unsaved document and selects
>> either Save or SaveAs before Closing. However, if the user press
>> Close or the "X" then that dialog displays. If the user choses
>> "Yes" then the FileSaveAs command is executed. The above code
>> doesn't intercept it so the file is saved and the bookmark isn't
>> inserted:
>>
>> I am trying to figure out how to capture what the user does when
>> Dialogs(98) is displayed???