NewProject event vs. Open Event

M

Mark Durrenberger

Hi all, I'm seeing strange things with the Open Event and the NewProject
event

When I This happens
Open new project (from file menu) new project event fires
open old project (from file menu) new project event fires,
Open does not fire (or does not appear to fire)
double click old project new project event
fires, open does not fire


Using Project 2003, I tested this with the following code in a class:

Public WithEvents MSProject As MSProject.Application

Private Sub MSProject_Open(ByVal pj As MSProject.Project)
MsgBox "OPEN Fired", vbOKOnly
End Sub

Private Sub MSProject_NewProject(ByVal pj As MSProject.Project)
MsgBox "NewProject Fired", vbOKOnly
End Sub

Why when I open an old project (from within project) does the NewProject
event fire
and the "Open" event not ever to fire???


--
_________________________________________________________
Mark Durrenberger, PMP
Principal, Oak Associates, Inc, www.oakinc.com
"Advancing the Theory and Practice of Project Management"
________________________________________________________

The nicest thing about NOT planning is that failure
comes as a complete surprise and is not preceded by
a period of worry and depression.

- Sir John Harvey-Jones
 
A

Abhijit

Yeah I am seeing the same error (I know this is three years after yo
reported the problem :
 
J

John

Abhijit said:
Yeah I am seeing the same error (I know this is three years after you
reported the problem :(

Abhjit,
OK, so what's your question?

John
Project MVP
 
A

Abhijit

Hi John,

I did exactly the steps mentioned above in three different environment
(all environments with MSProj 2003_:
1. VC6 + ATL. I can trap command bar / New / before save etc. events i
this add-in
2. VS2005 - Using C# and .NET
3. VS2005 - Using VB.Net

In all the three scenarios, I see that every time event related to NE
is fired irrespective if a new doc is opened or existing doc i
opened.

I see a small flaw in the design. The OPEN EVENT is owned by PROJEC
while NEW EVENT is owned by APPLICATON. Now to register an event, yo
need the respective object in place.

As when the addin is loading, there is no document hence looks like th
OPEN event is never honored by MSProj.

I performed one more test. I set my addin to load at startup. Close
MSProj and in Windows explorer double clicked an existing MPP file
MSProj loaded the file (not the blank file) but the event handle
called was NEW not OPE
 
J

John

Abhijit said:
Hi John,

I did exactly the steps mentioned above in three different environments
(all environments with MSProj 2003_:
1. VC6 + ATL. I can trap command bar / New / before save etc. events in
this add-in
2. VS2005 - Using C# and .NET
3. VS2005 - Using VB.Net

In all the three scenarios, I see that every time event related to NEW
is fired irrespective if a new doc is opened or existing doc is
opened.

I see a small flaw in the design. The OPEN EVENT is owned by PROJECT
while NEW EVENT is owned by APPLICATON. Now to register an event, you
need the respective object in place.

As when the addin is loading, there is no document hence looks like the
OPEN event is never honored by MSProj.

I performed one more test. I set my addin to load at startup. Closed
MSProj and in Windows explorer double clicked an existing MPP file.
MSProj loaded the file (not the blank file) but the event handler
called was NEW not OPEN

Abhijit,
I still don't see a question but if you are trying to interface Project
using something other than VBA (e.g. C# or VB.net) then you are beyond
my realm of knowledge.

I suggest you form a succinct question and then re-post. Hopefully one
of our more knowledgeable MVPs will respond.

Sorry,
John
 
A

Abhijit

John,

Sorry if I was cryptic. The question is simple. MSProject documentatio
allows me to handle NEW and OPEN messages.

Just wanted to trap the Open message so that when an existing file i
opened, I can do some preprocessing (like adding user defined view i
the document if not already existing etc)

Abhiji
 

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