Canceling the Before Save Event

Hello,

A good question came in yesterday; how to cancel the Project Before Save event in Project client:

Public Sub GlobalApplication_ProjectBeforeSave(ByVal pj As Project, ByVal SaveAsUi As Boolean, Cancel As Boolean)
 
         Cancel = True
      
End Sub

(For demonstration and simplicity, this event handler just cancels all saves. You would most likely want to add validation and if it fails, cancel the save)

Unfortunately the above code will not work. Instead, you will want to use ProjectBeforeSave2:

Public Sub GlobalApplication_ProjectBeforeSave2(ByVal pj As Project, ByVal SaveAsUi As Boolean, Info As EventInfo)

         Info .Cancel = True

End Sub

Hope this helps,

Chris Boyd

 

Technorati tags: Project Client, VBA, Events