I have a list of projects in Excel. I`d like to create those in Project 2007.
From the SDK it seems I can do that programmatically but is there an easier
alternative?
I created a macro you can find below. The macro expects to have an MS
Project file where:
"task name" is the name of the project to be created
- text1 is the first custom field to filled
- text2 is the secondo custom field to be filled
.....
- text9 is the ninth custom field to be filled.
For each task in the master project, the macro creates a new project,
sets the custom fields value, save the project to a project server and
finally publishes the project.
Before you run the macro you must change:
- the number of custom fields you need to fill
- the name of the custom field
- the name of the project server where data is saved
---------------------------------------------------------------------------------------------------------
Sub CaricamentoDati()
Dim oMasterProject As Project
Dim iCounter As Integer
Dim myTemp As Variant
Dim oTask As Task
Dim oNewProject As Project
Dim szNewProjectName As String
Dim szCustomField1 As String
Dim szCustomField2 As String
Dim szCustomField3 As String
Dim szCustomField4 As String
Dim szCustomField5 As String
Dim szCustomField6 As String
Dim szCustomField7 As String
Dim szCustomField8 As String
Dim szCustomField9 As String
szCustomField1 = "type of project"
szCustomField2 = "project category"
szCustomField3 = "it area"
szCustomField4 = "business"
szCustomField5 = "functional area"
szCustomField6 = "geographical area"
szCustomField7 = "requesting company"
szCustomField8 = "year"
szCustomField9 = "project budget"
myTemp = MsgBox("Attenzione la macro creerà tanti progetti quante sono
le righe del progetto attivo. Si desidera procedere?", vbYesNo,
"Conferma esecuzione macro")
If myTemp = vbNo Then End
'il master project è il progetto che contiene l'elenco dei progetti da
creare con i
'relativi campi custom da valorizzare. ogni attività del master
project rappresenta
'un progetto da creare.
Set oMasterProject = ActiveProject
For Each oTask In oMasterProject.Tasks
'il flag1 segnala se il progetto deve essere importato o meno
If oTask.Flag1 = True Then
szNewProjectName = oTask.Name
FileNew
Set oNewProject = ActiveProject
oNewProject.ProjectSummaryTask.SetField
FieldNameToFieldConstant(szCustomField1), oTask.Text1
oNewProject.ProjectSummaryTask.SetField
FieldNameToFieldConstant(szCustomField2), oTask.Text2
oNewProject.ProjectSummaryTask.SetField
FieldNameToFieldConstant(szCustomField3), oTask.Text3
oNewProject.ProjectSummaryTask.SetField
FieldNameToFieldConstant(szCustomField4), oTask.Text4
oNewProject.ProjectSummaryTask.SetField
FieldNameToFieldConstant(szCustomField5), oTask.Text5
oNewProject.ProjectSummaryTask.SetField
FieldNameToFieldConstant(szCustomField6), oTask.Text6
oNewProject.ProjectSummaryTask.SetField
FieldNameToFieldConstant(szCustomField7), oTask.Text7
oNewProject.ProjectSummaryTask.SetField
FieldNameToFieldConstant(szCustomField8), oTask.Text8
oNewProject.ProjectSummaryTask.SetField
FieldNameToFieldConstant(szCustomField9), oTask.Text9
FileSaveAs Name:="<>\" & szNewProjectName, FormatID:=""
Publish True, "
http://projectserver/PWA/" & szNewProjectName
FileCloseEx pjSave, , True
End If
Next oTask
End Sub