Feeds:
Posts
Comments

Archive for September, 2016


As we know, there are issues with having downloading project plans(local copy) from project pro and then re-synching them with server version, I won’t get into specific issues

In order to avoid this issue we had asked our users not use the the Save As command, but as you know guidelines almost never works 100% 😉

Hence we decided to block/Disable the Save As  functionality from Project Pro, what better way would it be other than a simple macro to prevent users to do a Save As

And so we wrote an event module, which overrides the Save As event and displays a message to user of this being disabled

Just for sake of completeness i have embedded my whole macro which ahs another function running for validating other ECF’s but not needed only to disable Save As

Step 1.  Check out Enterprise Global

Step 2.  Event and Class Module

Step 3. Save and checkin Ent Global

Note: Reopen project pro, connect to project server, open any project and then try to do Save As, see snapshots below

autoopenclassmodule

eventmodule

 

Save As Error.png

<Code>

Option Explicit
Option Base 1

Public WithEvents App As Application
Public WithEvents Proj As Project

Private Sub App_ProjectBeforeSave2(ByVal pj As Project, ByVal SaveAsUi As Boolean, ByVal Info As EventInfo)
Dim change As Integer
Dim msgRes As VbMsgBoxResult

If (App.Projects.Count > 0) Then
change = DetectInvalidEntries() ‘ this is a separate function to detect a specific Custom field value and allow user to save the project
If (change > 0) Then
msgRes = MsgBox(“For my Owner Org, Department should alwayss be India IT”, vbCritical, “Owner Org Change”)
‘Cancel the save
Info.Cancel = True
End If
End If

If (SaveAsUi) Then ‘Traps the SaveAsUi event and cancels the event
If ((InStr(UCase(App.UserName), “ADMIN”)) < 1) Then ‘ Check to Only allow Admin User to still use the functionality
MsgBox (“‘Save As’ function has been disabled, please contact Administrator”)
Info.Cancel = True
End If
End If
End Sub
Public Function DetectInvalidEntries() As Integer

Dim projectFieldDept, projectFieldPrjOwner As Long
Dim departmentsValue As String
Dim ProjOwnerOrg, scheduleDrivenCheck, multiDepartmentsCheck As Integer

‘Get the field values
projectFieldDept = FieldNameToFieldConstant(“Project Departments”, pjProject)
projectFieldPrjOwner = FieldNameToFieldConstant(“Owner Org”, pjProject)

‘See if the value changed
ProjOwnerOrg = InStr(ActiveProject.ProjectSummaryTask.GetField(projectFieldPrjOwner), “My Owner Org”)

‘load the Project Departments value
departmentsValue = ActiveProject.ProjectSummaryTask.GetField(projectFieldDept)
scheduleDrivenCheck = InStr(departmentsValue, “India IT”)
multiDepartmentsCheck = InStr(departmentsValue, “India IT,Manilla IT”)

‘Detect the change
If (ProjOwnerOrg > 0) Then
If (scheduleDrivenCheck > 0 Or multiDepartmentsCheck > 0) Then
DetectInvalidEntries = 1
End If
End If
End Function
‘—————Initiate the Event Class module for auto open——————–

Option Explicit

Dim x As New EventClassModule

Sub Auto_Open()
Set x.App = MSProject.Application
Set x.Proj = Application.ActiveProject
End Sub

</Code>

 

Read Full Post »