My VSTO project is having another problem when Word opens a document from a
URL when being hosted by IE. Almost immediately
the project calls the ThisDocument.SaveAs() method to give the document a
new name and
to make sure that the document is not in a read-only state.
The client is then free to edit the document. When done, they use a
"publish" button
on my Actions Pane that calls the ThisDocument.SaveAs() method twice to save
the document into the client's local Temp directory in two different
formats. It
then sends both copies of the document back to the server via an HTTP POST
request from a WebClient object. That all works fine.
The issue occurs when the client navigates IE away from the open Word
document, either forward to a new URL or backward via the browsers Back
button. If (and only if) changes have been made to the original document
opened by IE, they get asked whether or not they want to save changes. On
the surface this is not totally unexpected, however, a workaround suggested
in several
MSDN articles, I am setting the ThisDocument.Saved property to true during
my BeforeClose event handler (and also MANY other places in my code) to
avoid that dialog box. The original document read from the URL
should not have had any changes made to it as the first thing the project
did was to save it to a new name.
My project knows whether the document is dirty and would like to have full
control of all document saving.
It appears that the BeforeClose event is NOT being raised for my copy of the
ThisDocument object prior to the dialog box being presented. Separately, I
have also noted that if I press the Save button on Word's Standard
CommandBar, the BeforeSave event is not raised. This makes be believe that
my VSTO project's ThisDocument object is a copy of the document object
opened by IE
and not the actual document object. It also appears that some of the
document's
properties and events are being handled elsewhere and they are not being
reflected to my VSTO project.
If I could understand better what is happening here, I might have hope of
developing a workaround. If you would like me to move this discussion to
another thread or to another newsgroup, please let me know where you think
it should go. Thanks again for your past assistance.
Chuck Hartman
Iouri Simernitski (MS) - 27 May 2005 01:11 GMT
Chuck,
it sounds like this problem is an old acquaintance of mine.
http://groups-beta.google.com/group/microsoft.public.vsnet.vstools.office/br
owse_thread/thread/de2c2bdf1aa02e2f/6a42f762b7be237e
I hope this workaround is acceptable for you. BTW, you can pass null as the
filename, which would save to the last file the document was saved to.
iouri

Signature
This post is provided "AS IS" with no warranties, and confers no rights
Chuck Hartman - 31 May 2005 22:19 GMT
Iouri,
I have a few more cases to try, but it looks like this going to work. It
also may give me another approach to try for my CommandBar problem.
Thanks!!
Chuck Hartman
> Chuck,
> it sounds like this problem is an old acquaintance of mine.
[quoted text clipped - 6 lines]
>
> iouri