0
votes

Simple question however little information on this.

I am looking for examples of implementing the ProjectBeforePublish event in MSP VBA. For example, say I wanted to call a message box with string "something" before a project plan is published. How could this be done only on the publish event?

Is there a particular library I need to enable?

2

2 Answers

1
votes

For sure this is a POST 2010 feature but to enable it is sort of strange. You have to add a class module (I will call Mine 'EventClassModule') and it should contain the following code to get you started:

Option Explicit

Public WithEvents App As Application
Public WithEvents Proj As Project

Then in any other module create this sub routine and then run it to 'enable' the BeforePublish event (along with a bunch of other 'application' level events:

Option Explicit

Dim X As New EventClassModule

Sub Initialize_App()
  Set X.App = MSProject.Application
  Set X.Proj = Application.ActiveProject
End Sub

Once you run that Initialize sub you can go back to the EventClassModule and select 'App' from the "Object" drop down just above the code window (the drop down on the left.) once you do that you can click the "Procedure" drop down just to its right to pick the ProjectBeforePublish event.

0
votes

This is a MS Project 2013 feature onwards it seems... I have MS Project 2010.