Disabling a column

A

Ariel

Hi,
I am very new to Project and VBA for project.
Could someone tell me how I could disable a certain task
column, so that my users can't edit it ?

Thanks
Ariel
 
D

Deepu Chacko

Ariel,
The only way u can do that is to write events which would repond to any
change in the task information. Here is how you should do it.

1. Press Alt+F11 on the project professional to come to VBA editor.
2. Click on View -> Project Explorer
3. Click on Insert -> Class Module ( assume the new class is created with
the name as Class1 )
4. Paste the following code ( note there are comments alongwith the code to
help u out ) Assume that u dont want the TaskName to be changed after the
actuals have come in

'We require a handle to the Application to trap the events.
Public WithEvents ActiveApplication As Application

'This event will fire before a task is changed.
Private Sub ActiveApplication_ProjectBeforeTaskChange(ByVal tsk As Task,
ByVal Field As PjField, ByVal NewVal As Variant, Cancel As Boolean)
'Check if the Task Name is the field that is being modified
If Field = pjTaskName Then
If tsk.PercentWorkComplete > 0 Then
'If the Percent Work Complete is greater than zero which means
that the actuals have come in. Cancel the event.
Cancel = True
End If
End If
End Sub

5. The above code fires when a task is fired, now we should write to code to
invoke this method. The below code should be written in the Project_Change
event.
To do that first open the code window for the Project
a. On the Project Explorer expand the folder: Microsoft Project Objects
b. Right click on "This Project" class and click on "View Code"
c. Paste the below code in the code window
Private Sub Project_Change(ByVal pj As Project)
Dim clsEventModule As New Class1
'Initialize the module variable to the current
application so that the events fire.
Set clsEventModule.ActiveApplication = Application
End Sub

6. Your project is ready now !!! Try changing the Task Name after making the
%WorkComplete greater than zero.

Let me know if it helps
 
J

Jack D.

Ariel said:
Hi,
I am very new to Project and VBA for project.
Could someone tell me how I could disable a certain task
column, so that my users can't edit it ?

Thanks
Ariel

IF they are not very sophisticated you can simply hide the column. Select
the column header and hit delete.
If they need to see the data, use a formula in a user defined field like
Text1 to show the information.

For example if I had information in the contact fields which I wanted to
show, but not allow users to change I would
Delete the original contact column
Go to insert menu.
Insert an unused user defined field (lets say text 9 for example).
Right click on the text9 column header, select customize.
Rename the field to "contact"
Click on the formula button.
enter the following formula

[Contact]

then click OK
Now the new field will show the information in the contact field, but it
won't let the users change it.
They could still insert the original contact field and edit it, but
generally most users won't bother.


--
Please try to keep replies in this group. I do check e-mail, but only
infrequently. For Macros and other things check http://masamiki.com/project

-Jack Dahlgren, Project MVP


+++++++++++++++++++
 

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