Hmm, not easily done.
Because you can't block a user from navigating from one doc to the other,
you'll have to
find a way to impose this/force this.
One way:
In Doc1 (or the Doc1's source template) you'll have to write code
blocking the Document Change event.
You're not there yet with blocking using the application event, you will
also need
a flag to release the blocking on the application level.
One way of doing this is to create a Custom Document property in Doc1 (or
it's source template)
for instance: "ReleaseDocChange" of type "Yes/"No"
The coding scenario would be:
Create the Custom Document property in Doc1 (or it's source template) and
set the value to "Yes"
When the commandbutton on Doc1 is clicked, toggle the custom document
property to "No"
Create the application event:
http://word.mvps.org/faqs/macrosvba/AppClassEvents.htm
and
http://msdn2.microsoft.com/en-us/library/Bb221264.aspx
Code could look like
(whereby "app" is the application variable; look at above 2 articles)
Private Sub app_DocumentChange()
If ThisDocument.CustomDocumentProperties("ReleaseDocChange").Value =
"No" Then
Set app.ActiveDocument = Documents("Doc2")
Documents("Doc2").Activate
End If
End Sub
In the click event of the commandbutton on Doc2, toggle the flag or custom
document property to "Yes"
to release a normal behaviour of Document Change application event.
Try to implement, and repost if you get stuck indicating which Word version
y're running
and relevant snippets of the offending code.
--
Krgrds,
Perry
System:
Vista/Office Ultimate
VS2005/VSTO2005 SE