Document_Open/Created events not triggered, when Doc opened in VBA???

Started by Jumpy, April 08, 2010, 06:22:29 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Jumpy

Good morning,

I made a template, that contains VBA in the ThisDocument Modul and uses the Document_open and Document_created events, to do certain things.
When I start a new drawing based on this template manually it works fine.

But when I'm in another drawing (which shall become my custom made startcenter), from where I want to start a new drawing based on that template, I want use the Document.Open(path\filename) or Document.Add(path\filename) methods. It works in so far, as that the document is opened or created, but the events in the new document (based on the template) don't get triggered.

Has anyone an idea why and whats to do? It's urgent because I need it working on a meeting this afternoon.

Yacine

if it's so urgent, can you send some code/vsd/vst? I'll have a look (no success garantee ;) )
Yacine

Jumpy

OK. The situation in short. It is not possible to start with a certain .vst from the desktop, but you can start any .vsd with a Desktop-Link to Visio that contains the path of the drawing as command-line-parameters.

I use this to start my drawing ...path\Start.vsd.
This drawin is empty except the following code in the ThisDocument modul:


Private Sub Document_DocumentOpened(ByVal doc As IVDocument)
Application.Documents.Add ("Meine-Vorlage.vst")
'Application.Documents.Open ("Meine-Vorlage.vst")    <-- Doesn't work, too
doc.Close
End Sub


This creates or opens a new drawing, based on my template, which has the following code in the ThisDocument modul:

Somehow is a added document not opened or created?????

Yacine

your code worked just fine. However, I specified the whole path.
Yacine

Jumpy

I made an error while editing my last post and deleted the interesting part (code).
That is the code in the new document wich is opened/created from the old document.
And that is the code that isn't working, because it doesn't seem to get triggered somehow.
The MsgBox is only to show me if the code starts.


Option Explicit
Private WithEvents ThePage As Visio.Page
'------------------------------------------------
Public Sub Restart()
Set ThePage = Visio.ActivePage
End Sub
'--------------------------------------------------------------------
Private Sub Document_DocumentOpened(ByVal doc As Visio.Document)
Set ThePage = Visio.ActivePage
MsgBox 1
End Sub
'------------------------------------------------------------------
Private Sub Document_DocumentCreated(ByVal doc As IVDocument)
  Set ThePage = Visio.ActivePage
  MsgBox 2
End Sub