ProjectBeforeSave vs. publish event

K

Krizz

Hey i am using VBA (or VB.net or C#.net) to capture the ProjectBeforeSave
event and the ProjectBeforePublish event.
When i get to ProjectBeforeSave i would like to now if the publish button
was pressed or the save button was pressed.

I am using MSProject 2007 and Project Server 2007.

So basically i want to following functionality:

Private Sub MSProjApp_ProjectBeforePublish(ByVal pj As
Microsoft.Office.Interop.MSProject.Project, ByRef Cancel As Boolean) Handles
MSProjApp.ProjectBeforePublish
If CheckDbSapTasks(True) = True Then
Cancel = True
End If
End Sub

Private Sub MSProjApp_ProjectBeforeSave(ByVal pj As
Microsoft.Office.Interop.MSProject.Project, ByVal SaveAsUi As Boolean, ByRef
Cancel As Boolean) Handles MSProjApp.ProjectBeforeSave
If not publishing then
CheckDbSapTasks(False)

End If
End Sub
 
R

Rod Gill

I would declare a global variable (at top of file) and set this in one sub
so it can be read in the other.

--

Rod Gill
Microsoft MVP for Project - http://www.project-systems.co.nz

Author of the only book on Project VBA, see: http://www.projectvbabook.com




Krizz said:
Hey i am using VBA (or VB.net or C#.net) to capture the ProjectBeforeSave
event and the ProjectBeforePublish event.
When i get to ProjectBeforeSave i would like to now if the publish button
was pressed or the save button was pressed.

I am using MSProject 2007 and Project Server 2007.

So basically i want to following functionality:

Private Sub MSProjApp_ProjectBeforePublish(ByVal pj As
Microsoft.Office.Interop.MSProject.Project, ByRef Cancel As Boolean)
Handles
MSProjApp.ProjectBeforePublish
If CheckDbSapTasks(True) = True Then
Cancel = True
End If
End Sub

Private Sub MSProjApp_ProjectBeforeSave(ByVal pj As
Microsoft.Office.Interop.MSProject.Project, ByVal SaveAsUi As Boolean,
ByRef
Cancel As Boolean) Handles MSProjApp.ProjectBeforeSave
If not publishing then
CheckDbSapTasks(False)

End If
End Sub



__________ Information from ESET Smart Security, version of virus
signature database 4942 (20100313) __________

The message was checked by ESET Smart Security.

http://www.eset.com

__________ Information from ESET Smart Security, version of virus signature database 4942 (20100313) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
K

Krizz

Yes, but i want to know if i am publishing in the save method.
The save event is triggered first then the pulish event, so how do i now if
i am publishing in the save method?
 
R

Rod Gill

I don't see your problem here as a publish can only occur after a save. What
exactly is causing you a problem?



--

Rod Gill
Microsoft MVP for Project - http://www.project-systems.co.nz

Author of the only book on Project VBA, see: http://www.projectvbabook.com




Krizz said:
Yes, but i want to know if i am publishing in the save method.
The save event is triggered first then the pulish event, so how do i now
if
i am publishing in the save method?



__________ Information from ESET Smart Security, version of virus
signature database 4944 (20100314) __________

The message was checked by ESET Smart Security.

http://www.eset.com

__________ Information from ESET Smart Security, version of virus signature database 4944 (20100314) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
K

Krizz

OK, thank you for your patience.

I want to display a msg box in the save event.
I want to display a different msg box in the publish event.

If the publish event is triggered the save event is allso triggered
(automaticaly), in this case i only want to display the msg box for the
publish event.
 
R

Rod Gill

By design, events are individual "happenings". As such you have no way of
determining whether this is the first of 1,2 or 100 repeats so I think you
are out of luck.

All I can suggest is a single message that works for either, and only
display it in the save event.

--

Rod Gill
Microsoft MVP for Project - http://www.project-systems.co.nz

Author of the only book on Project VBA, see: http://www.projectvbabook.com




Krizz said:
OK, thank you for your patience.

I want to display a msg box in the save event.
I want to display a different msg box in the publish event.

If the publish event is triggered the save event is allso triggered
(automaticaly), in this case i only want to display the msg box for the
publish event.



__________ Information from ESET Smart Security, version of virus
signature database 4946 (20100315) __________

The message was checked by ESET Smart Security.

http://www.eset.com

__________ Information from ESET Smart Security, version of virus signature database 4946 (20100315) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
K

Krizz

But the publish event it is only one event, this triggers the save event if
the project is not allready saved.
The problem is VBA code will recieve the save event first then the publish
event, even thogh the publish event is triggered first in MS Project.

I can't be the only one with this problem.
 
R

Rod Gill

I've never heard of anyone displaying a message every time the project is
saved or published before. My users would complain bitterly! So you may well
be the first with this problem!

--

Rod Gill
Microsoft MVP for Project - http://www.project-systems.co.nz

Author of the only book on Project VBA, see: http://www.projectvbabook.com




Krizz said:
But the publish event it is only one event, this triggers the save event
if
the project is not allready saved.
The problem is VBA code will recieve the save event first then the publish
event, even thogh the publish event is triggered first in MS Project.

I can't be the only one with this problem.



__________ Information from ESET Smart Security, version of virus
signature database 4950 (20100316) __________

The message was checked by ESET Smart Security.

http://www.eset.com

__________ Information from ESET Smart Security, version of virus signature database 4950 (20100316) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
K

Krizz

Yes, the msgbox shouldnt be displayed all the time, just on some conditions.

However it sucks there is no solution to this.

Anyway thank you for your help Rod Gill, i appriciate it :)
 
R

Rod Gill

Good Luck and happy programming!

--

Rod Gill
Microsoft MVP for Project - http://www.project-systems.co.nz

Author of the only book on Project VBA, see: http://www.projectvbabook.com




Krizz said:
Yes, the msgbox shouldnt be displayed all the time, just on some
conditions.

However it sucks there is no solution to this.

Anyway thank you for your help Rod Gill, i appriciate it :)



__________ Information from ESET Smart Security, version of virus
signature database 4953 (20100317) __________

The message was checked by ESET Smart Security.

http://www.eset.com

__________ Information from ESET Smart Security, version of virus signature database 4953 (20100317) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 

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