Daryl,
I'd add two custom command bar buttons (Open from Repository and Save to
Repository), connect to the Save, Save As, Save All, etc built-in command
bar buttons (you can find their IDs with our free Built-in Controls
Scanner -
http://www.add-in-express.com/downloads/controls-scanner.php) and
intercept corresponding keyboard shortcuts. In the event handlers of the
custom buttons above, I'd show appropriate dialogs. In the events of the
built-in controls, I'd recognize if the document should be saved to
Repository and execute a respective routine.
To add a custom button to the Standard command bar, use the Application
object supplied in the StartupComplete event to create a button (CType may
be required):
Dim WithEvents myControl as Office.CommandBarButton =
wordApplication.CommandBars("Standard").Controls.Add(msoControlButton).
Then set other command bar button properties (Caption, ShortcutText, Style,
State, BeginGroup, Visible) and handle the Click event of myControl.
You have to handle the scenario when the button has already been added to
the command bar. When switching to another document, you have to create (or
connect to) the button anew. Be aware, the button may become disconnected
all of a sudden. That is, you should be ready to re-connect it. You should
also take care of your command bars and buttons not being shown in Outlook
e-mail inspectors when Word is set as the default mail editor. To handle
keyboard shortcuts, you have to do some Win32 API programming. In addition,
if you use PIAs, you can support the only Word version. To make your add-in
trusted in Office, you have to sign its starting-point DLL with a strong
key. It isn't possible if you use the Shared Add-in wizard in VS: shared
add-in has MSCOREE.DLL as its starting-point DLL.
All this stuff is included in Add-in Express that provides version-neutral
PIAs (
http://www.add-in-express.com/docs/net-tips.php#What are PIAs), an
add-in loader of its own
(
http://www.add-in-express.com/docs/net-deploying-addins.php), as well as
command bar, command bar control and keyboard shortcut components
(
http://www.add-in-express.com/docs/net-components.php)
To handle events of a document, connect to it in an appropriate event of
Word.Application object. To determine if the BeforeDocumentSave event is
invoked by some user actions or by Word's AutoSave feature, see the
"BeforeDocumentSave Event" topic in this newsgroup.
Hope this helps.
Regards from Belarus,
Andrei Smolin
Add-in Express Team Leader
www.add-in-express.com