Intercepting "Save" and "Save as..." commands

N

nbelyh

How do I intercept "Save" and "Save as..." commands *before* save
starts?

I want to prevent the user from saving the document under certain
conditions.

Is there an event like QuerCancelSave (I suppose that no)...
In this case, how can I "emulate" this?

Now I have only the idea of replacing all "Save" commands in user UI
with "own versions" (mapping to addin) that redirect calls if needed to
Application->DoCmd.

Is there any other way to do that?
 
P

Paul Herber

How do I intercept "Save" and "Save as..." commands *before* save
starts?

I want to prevent the user from saving the document under certain
conditions.

Is there an event like QuerCancelSave (I suppose that no)...
In this case, how can I "emulate" this?

Now I have only the idea of replacing all "Save" commands in user UI
with "own versions" (mapping to addin) that redirect calls if needed to
Application->DoCmd.

Is there any other way to do that?

The events are :
BeforeDocumentSave
BeforeDocumentSaveAs
both visible from the Application and Document objects.
 
N

nbelyh

The events are :
BeforeDocumentSave
BeforeDocumentSaveAs
both visible from the Application and Document objects.

Thank you for response.

But.
These events occur AFTER saving has been already initiated
I thought that there is no ability to ABORT document saving from
withing these events handlers (was I wrong?)

What we need, is an ability to PREVENT the document from saving under
certain circumstances.

Regards, Nikolay.
 
P

Paul Herber

Thank you for response.

But.
These events occur AFTER saving has been already initiated
I thought that there is no ability to ABORT document saving from
withing these events handlers (was I wrong?)

What we need, is an ability to PREVENT the document from saving under
certain circumstances.

Ok, so what I think you might have to do is to modify the menus and
disable the appropriate menu entries. Repeat for the toolbar as well.
 
K

Kari Yli-Kuha

nbelyh said:
Thank you for response.

But.
These events occur AFTER saving has been already initiated
I thought that there is no ability to ABORT document saving from
withing these events handlers (was I wrong?)

What we need, is an ability to PREVENT the document from saving under
certain circumstances.

Have you considered "greying" the Save/SaveAs menu items?
Regards, Nikolay.


/C
 
N

nbelyh

Ok, so what I think you might have to do is to modify the menus and
disable the appropriate menu entries. Repeat for the toolbar as well.

Yes, That is just what I have meant in the first post...
Not disabling, but "redirecting", since we need to disable save only
under certain circumstatnces :)

But we don't want this way... This way has some drawbacks, like
undesirable "interferrention" with other third-party add-ins that can
stop working, slow UI updates (flickering), and other stuff...
It would be nice to have another option.... The question is just about
that.

Actually, all this stuff is needed to protect diagrams (hm,
intellectual property).
Diagram are stored in the database as password-protected zipped BLOBs,
and retrieved to the local machine for editing. The user should not be
able to copy diagrams at his wish, but only under a strict control from
our side :)

Regards, Nikolay.
 
N

nbelyh

The BeforeSave events are to allow you to do cleanup before Visio loses
focus. You are already committed when you reach this event. You should be
looking at the CancelQueryxxx events to determine if you want to bail.

Yes, yes!
But, there is nothing like "QueryCancelDocSave"... :(
That is the problem.

It seems that actually we have no choice - we are forced to emulate
this missing event using the technique described - setting "Save as..."
menu item's Action property to RUNADDONWARGS(), pointing to our
addon...

But this is such a pain! :) Running through all
menu/toolbars/accelerators looking for "save.." commands, and
redirecting them... Intercepting user interface customizations, and
repeating the above process for cutomized version...

May be there is some Visio feature that could simplify this task?
For example, is it possible to intercept (in a plugin) user interface
commands before they are routed to visio?

Regards, Nikolay.
 

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