News:

BB code in posts seems to be working again!
I haven't turned on every single tag, so please let me know if there are any that are used/needed but not activated.

Main Menu

ActiveXcmd bugs sub: ThisDoc.Saved = True & ThisDoc.Close | solved! but REASON?

Started by RSut, March 30, 2014, 07:49:00 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

RSut

****** Story of a bug, with a work-around, but without any explanation.
****** Can you explain, or is is just that activeX buttons should be avoided?

During a pilot expt in  VBA  to test automated closure of a visio doc (with and without ThisDocument.Save /ThisDocument.Saved=1 ), I set up an *activeX command button* on the visio drawing page to test occurrence of 'save'.

I was surprised to find that clicking the *activeX command button*, just once, stopped Sub CloseNoSave() from functioning (the doc did not close). This occurred even when the sub for the activeX button_click event contained NO content code (eg, no call to drive another procedure), and even if the button had NO code at all (as for activeX Button on page-3 of attached file).

Here is the code that was stopped by clicking activeX button BEFORE running this sub:
Sub CloseNoSave()
    Application.AlertResponse = 1
    ThisDocument.Saved = True
    ThisDocument.Close
    'Application.Quit
End Sub

The activeX button did not stop the function of Sub CloseWithSave():
Sub CloseWithSave()
    Application.AlertResponse = 1
    ThisDocument.Save
    ThisDocument.Close
    'Application.Quit
End Sub

UserForm cmd buttons had NO such effect. But clicking a visio shape (not even selecting it) was sufficient to cause this stoppage, PROVIDED that an activeX button was located somewhere on the same page!.

A SOLUTION: This block was reproducibly overcome with an automatic change of page to a new and irrelevant page (here: "Page-2"). As the code line that followed still closed the document without change, this page change is not saved:

Here is the modified code:
Sub CloseNoSave()
    Application.ActiveWindow.Page = Application.ActiveDocument.Pages.ItemU("Page-2")
    Application.AlertResponse = 1
    ThisDocument.Saved = True
    ThisDocument.Close
    'Application.Quit
End Sub

This issue does not occur Excel.
Can anyone explain what is going on here?
File attached!

Thanks,
RSut

Browser ID: smf (possibly_robot)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 143 (show)
Files included: 34 - 1306KB. (show)
Memory used: 1048KB.
Tokens: post-login.
Cache hits: 13: 0.00103s for 26,764 bytes (show)
Cache misses: 2: (show)
Queries used: 15.

[Show Queries]