M
Mark de Waal
Hi all,
I'm trying to create a project in MS Project and populate it with tasks
through automation via a VBScript. This works, but the performance is very
bad and I do not know what I am doing wrong. As an example I wrote this
script:
set oMSPApp = CreateObject("MSProject.Application")
set oProject = oMSPApp.Projects.Add()
nTime = Time()
for i = 1 to 10
AddTask("Task" & i)
next
msgbox "Elapsed time: " & (Time() - nTime) * 86400 & " seconds"
oMSPApp.Visible = True
set oProject = nothing
set oMSPApp = nothing
sub AddTask(sTaskName)
set oTask = oProject.Tasks.Add(sTaskName & " " & Time())
with oTask
.Estimated = 0
.OutlineLevel = 1
.EffortDriven = False
.ConstraintDate = Date
.ConstraintType = 2 'Must start on
.Start = Date
.Duration = "5d"
.Milestone = False
.PercentComplete = 25
end with
set oTask = nothing
end sub
The execution of this script takes aprox. 14 seconds on my pc (P4HT, 3.2Ghz,
WinXP SP2)
I noticed the following:
1. If I set more task properties, the execution takes more time
2. When I run the VBScript again (with MS Project visible) I can see how
slow the execution is.
3. It makes no difference if the option "Calculation" is set to Automatic or
Manual
4. When I activate the VBA editor in MS Project (alt+F11) and run the
VBScript again (with MS Project still running), it only takes 1 second to
execute the VBScript!
What am I doing wrong here? Did I forget to set an option? Is this a
security issue? Or a WinXP SP2 issue?
Regards,
Mark de Waal
I'm trying to create a project in MS Project and populate it with tasks
through automation via a VBScript. This works, but the performance is very
bad and I do not know what I am doing wrong. As an example I wrote this
script:
set oMSPApp = CreateObject("MSProject.Application")
set oProject = oMSPApp.Projects.Add()
nTime = Time()
for i = 1 to 10
AddTask("Task" & i)
next
msgbox "Elapsed time: " & (Time() - nTime) * 86400 & " seconds"
oMSPApp.Visible = True
set oProject = nothing
set oMSPApp = nothing
sub AddTask(sTaskName)
set oTask = oProject.Tasks.Add(sTaskName & " " & Time())
with oTask
.Estimated = 0
.OutlineLevel = 1
.EffortDriven = False
.ConstraintDate = Date
.ConstraintType = 2 'Must start on
.Start = Date
.Duration = "5d"
.Milestone = False
.PercentComplete = 25
end with
set oTask = nothing
end sub
The execution of this script takes aprox. 14 seconds on my pc (P4HT, 3.2Ghz,
WinXP SP2)
I noticed the following:
1. If I set more task properties, the execution takes more time
2. When I run the VBScript again (with MS Project visible) I can see how
slow the execution is.
3. It makes no difference if the option "Calculation" is set to Automatic or
Manual
4. When I activate the VBA editor in MS Project (alt+F11) and run the
VBScript again (with MS Project still running), it only takes 1 second to
execute the VBScript!
What am I doing wrong here? Did I forget to set an option? Is this a
security issue? Or a WinXP SP2 issue?
Regards,
Mark de Waal