DocumentAfterClose event?

D

David Thielen

Hi;

The DcoumentBeforeClose event is fired before the user is prompted if they
want to save the document (if dirty). In that case they can press cancel and
the document is not closed.

What event fires when the document is closed or is closing and will
definitely close?
 
D

David Thielen

Hi;

I need the oppisate, where I get an event when the document is going to be
closed for sure.
 
J

Jack

Could you not automate the save/no save functionality in the
documentBeforeClose event? Something like this:
sub objItem_Close (cancel as boolean)
if msgbox ("Save?", vbYesNo)=VBYes then
objItem.close olsave
else
objItem.close oldiscard
end sub
cancel = true
end sub


jack


In other words check the saved propety if not set then prompt to save, then
call the save (if yes selected) and close olDiscard method?
 
D

David Thielen

I really dislike that idea because MS can come out with a new version where
that dialog box looks different or has different controls and if my Add-In is
running, they don't have the standard.
 
P

Peter Huang [MSFT]

Hi

So far as workaround, you need to handle the DocumentBeforeClose event.
And then then call the Document.Save or Document.SaveAs to save the
document to disk for sure.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

David Thielen

Hello;

Ok, it looks like we have to intercept this message and prompt the user as
you suggested. Which leads to the question, what is the text Word puts up in
that message box for every language Word supports? (I don't want to put up an
English language prompt if someone is using the Chinese language version of
Word.)

And how do we get the language Word is using for its UI?
 
D

David Thielen

Oh, and is there anything special I have to do in the message box for
hebrew/arabic?
 
P

Peter Huang [MSFT]

Hi David,

I did not have Office with hebrew/arabic version for test.
But I think in the event handle function, we did not need to pop up a
Office dialog. We can show an our dialg developped by ourself, so that we
can control the text to show.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

David Thielen

Correct, I will pop up my own dialog asking them if they want to save the
file or cancel.

But if they are running the Chinese version of Word, I don't want to ask the
question in English. So I need to know what text to put up for my message
based on the language version of Word they are running.
 
P

Peter Huang [MSFT]

Hi

Based on my understanding, you want to do Internationalization based on the
customer's language version.

Here is the links for your reference.
International Programming
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html
/_core_international_programming_topics.asp

Basics of .NET Internationalization
http://msdn.microsoft.com/msdnmag/issues/04/03/Bugslayer/default.aspx

Also you can reference the link below to find how to read the registry to
decide current user's office language version
Customizing Language Features
http://office.microsoft.com/en-us/assistance/HA011363781033.aspx

We need to prepare multiple languages' strings.
e.g. when we found the office is of english version, we need to load the
english version string and pop up in our dialog, this is what
Internationalization did.

For detailed information, you may try to post in the newsgroup about
Internationalization.
microsoft.public.win32.programmer.international




Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

David Thielen

Hi;

That gives me half of it. Now, how do I find out the text Word uses for that
MessageBox in each language?
 
P

Peter Huang [MSFT]

Hi Dave,

Do you mean the MessageBox which is shown by msgbox?
The Concrete description is defined by msgbox parameter.
e.g.
msgbox "string"
what is the string's language should be decided by your program.

If you mean the "OK" button text, you can call GetSystemDefaultUILanguage
API to get the system's default UI lanuage to get the information.
For the details information please post in the International newsgroup, it
is a internationalization realated question

Thanks for your understanding!

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

David Thielen

Hello;

Yes I mean the MessageBox. But I need to know what text Word puts in it for
the Yes/No/Cancel prompt when a user closes a document that is dirty.

For example, if somone is using the Chinese version of Word, when we put our
own MessageBox up instead of letting Word do it, we need to have the same
text in han characters that Word would have. A user is going to be very
unhappy if that MessageBox suddenly starts appearing in English.

Since we are replacing a Word MessageBox, we need to know the text Word puts
in there for each language. How do we get that? (This is why the work-around
you propose is so difficult.)
 
P

Peter Huang [MSFT]

Hi Dave,

I think we have some misunderstanding here.
e.g.
Private Sub wdApp_DocumentBeforeSave(ByVal Doc As Document, SaveAsUI As
Boolean, Cancel As Boolean)
SaveAsUI = True
Cancel = True
MsgBox "Content", vbOKCancel, "Title"
End Sub

The VB a Code will show a messagebox.
Prompt String: Content -------------- English
Tow buttons: OK, Cancel ----------- English
Title: Title --------------------------------- English

The "Prompt String" and the "Title" can be controlled in the MsgBox call.

If we call MsgBox "ÖÐÎÄ", vbokcancel,"±êÌâ", then it will show the chinese
character even if we install an english version.

But the Button's text on the MessgeBox is not controled by us. It is
controled by Operation system.
We use the API below to check.
GetSystemDefaultUILanguage


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

David Thielen

Hello;

Yes, but the prompt & title are set by Word. I need to know the prompt &
title Word uses in each language for the MessageBox that in English says: "Do
you want to save the changes to Document1?"

If someone is using the Chinese version of Word, and the document is dirty,
and they chose to close the document, they do not want a MessageBox that asks
them in English "Do you want to save the changes to Document1?"

The Yes/No/Cancel will appear in Chinese. But the text & caption need to
also. So how do I get that text from Word for each language?
 
P

Peter Huang [MSFT]

Hi

Based on my understanding, so far we are handling the DocumentBeforeSave
event and set the Cancel = True SaveAsUI = True, so that the Word's
MessageBox will not show.
We just call the code below to show the messagebox.
MsgBox "Content", vbOKCancel, "Title"
So we can control what to show(English or other language)?

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

David Thielen

Correct. But when I display that dialog box, I want it to look like the
dialog box from Word. To do that, I need to know what Word's dialog says in
each language.
 
P

Peter Huang [MSFT]

Hi Dave,

Based on my research, there is no such a list to list all the language
versions for the Word Save dialog.
So far I think you have to test on every language version to get the
language you want.

Thanks for your understanding!

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

David Thielen

Ok, that is impossible. So it brings us back to the original question, how do
I get an event after the Save/no save/cancel dialog?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top