Visio Guy

Visio Discussions => Programming & Code => Topic started by: vba_forever on November 09, 2012, 09:39:31 PM

Title: catching visio close event
Post by: vba_forever on November 09, 2012, 09:39:31 PM
Once the close Visio button has been clicked, is there a way to catch the event and still access page objects/data?

There seems to be a significant difference between the BeforeClose() routine of Excel and Visio.  In Excel, there is a cancel variable that can be set to true or false, so that the code can halt the exit of the document.  Also, all of the Excel information is still available (sheet, cells, vba globals, etc).  In Visio, it seems that once the Document_BeforeDocuementClose code is executed, the Visio document (but not the vba component) has already been closed.  This is supported by the absence of the cancel variable.  Any attempt to reference a sheet or shape is met with "undefined value".

Does the Excel version of BeforeClose() exist in visio?

I am running Excel and Visio 2010.

thanks in advance!
Title: Re: catching visio close event
Post by: AndyW on November 12, 2012, 08:18:39 AM
You need to use the QueryCancelDocumentClose event, that way you can prevent it being closed etc
Browser ID: smf (is_webkit)
Templates: 1: Printpage (default).
Sub templates: 4: init, print_above, main, print_below.
Language files: 1: index+Modifications.english (default).
Style sheets: 0: .
Hooks called: 44 (show)
Files included: 25 - 925KB. (show)
Memory used: 761KB.
Tokens: post-login.
Cache hits: 7: 0.00108s for 22,301 bytes (show)
Cache misses: 1: (show)
Queries used: 9.

[Show Queries]