DocumentOpened /-Created-Events don't fire when Document is opened by Code

Started by Jumpy, July 09, 2012, 02:46:59 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Jumpy

Hello,

I think I asked this before, but can't find it again and I want to bring this up.
Especially I'm interested if someone can duplicate the problem and if it's still there in Visio2010 (I have only 2007).

I have a drawing with code in the DocumentOpened-Event and in the DocumentCreated-Event.
For example a simple MsgBox "Hello World".
I save the drawing as drawing and a copy as template.

From a different drawing I want to open the drawing or the template (with VBA). It doesn't matter if I use Open, OpenEx or Add (for the template). The Event in the opened/created document won't fire.

aledlund


Jumpy

I think not. I use only the usual VBA commands. For example: It is so important for me, that the DocumentOpened or -Created Events fire, beacause I use them ti fill a "With Events"-variable.

But maybe I have a false understanding of persistent events? It is a mechanism used from AddOns?? I read about it in books, but at the moment I live with VBA-Code in Template and Stencil. Someday I'll move on to that, i hope.

aledlund

The persistent events can be used within VBA. There is example code in SDK on working with AddAdvise. Because the persistent events are tied to the document, they will work with templates (and the documents that are created by that mechanism). I understand that there is a learning curve, but it is fairly easy (although the sample code is long, most of it is rarely used).
Al

aledlund

One other thing to investigate. Sometimes operations get wrapped in a ScopeId and the internal events are handled within the scope before it is passed back to the caller. I'd turn on the event monitor in the developer environment to see what is happening when you open your document.
al

Jumpy


aledlund

Jumpy,
I think I may have the same issue. I can see it in the event monitor, but the vba code doesn't fire.
al

aledlund

turned out mine was self-inflicted, I had a withevents that was capturing visio.document.
al