D
Duncan
Hi All,
I'm fairly new to creating office addins and have stumbled across the
following problem that I hope you could help me out with.
The concept:
I have a windows form based addin that creates data graphically and stores
it in a custom class, instances of which are referenced using "Items(i)"
where i is the indexing integer. The plan is once having created this data on
the form, I could use it to populate MS Project with Tasks where one instance
of my Items class corresponds to one Task in project.
The Problem:
The issue I have is that when using the function:
CurrentProject.Tasks.Add(NewTask)
This works for one task, but I wish to place this line in a Do Loop and at
the moment whenever this line is executed, the task is added, but the addin
closed before getting to the next command. When stepping through the code, it
doesn't show any errors or out of bound variables, it simply executes Add
function and drops back to project closing the addin in the process.
Supporting info:
The current instance of MS Project is declared as follows:
(in connect.vb OnConnection):
applicationObject2 = application
(in connect.vb MyMenuEventHandler):
'show form with tools on
Dim PCLMngForm As New PCLMngFrm
'set appinstance to this application
PCLMngForm.AppInstance = applicationObject2
PCLMngForm.ShowDialog()
(in PCLMngFrm.vb):
Public Items(10000) As Item
Public AppInstance As Microsoft.Office.Interop.MSProject.Application
(in PCLMngFrm.vb AddToProjectCmd_Click):
Dim CurrentProject As Project
CurrentProject = AppInstance.ActiveProject
Dim NewTask As Task
Dim i As Integer = 0
Do Until Items(i) Is Nothing
NewTask =
CurrentProject.Tasks.Item(CurrentProject.Tasks.Count)
NewTask.Name = Items(i).Name
NewTask.Notes = Items(i).Notes
CurrentProject.Tasks.Add(NewTask)
i += 1
Loop
(System / Software Config):
Windows 2k SP4
Visual Studio 2003 Pro
MS Project 2003 Standard
It's probably something silly that I've missed, but any help would be
greatly received.
Thanks in advance,
Duncan
I'm fairly new to creating office addins and have stumbled across the
following problem that I hope you could help me out with.
The concept:
I have a windows form based addin that creates data graphically and stores
it in a custom class, instances of which are referenced using "Items(i)"
where i is the indexing integer. The plan is once having created this data on
the form, I could use it to populate MS Project with Tasks where one instance
of my Items class corresponds to one Task in project.
The Problem:
The issue I have is that when using the function:
CurrentProject.Tasks.Add(NewTask)
This works for one task, but I wish to place this line in a Do Loop and at
the moment whenever this line is executed, the task is added, but the addin
closed before getting to the next command. When stepping through the code, it
doesn't show any errors or out of bound variables, it simply executes Add
function and drops back to project closing the addin in the process.
Supporting info:
The current instance of MS Project is declared as follows:
(in connect.vb OnConnection):
applicationObject2 = application
(in connect.vb MyMenuEventHandler):
'show form with tools on
Dim PCLMngForm As New PCLMngFrm
'set appinstance to this application
PCLMngForm.AppInstance = applicationObject2
PCLMngForm.ShowDialog()
(in PCLMngFrm.vb):
Public Items(10000) As Item
Public AppInstance As Microsoft.Office.Interop.MSProject.Application
(in PCLMngFrm.vb AddToProjectCmd_Click):
Dim CurrentProject As Project
CurrentProject = AppInstance.ActiveProject
Dim NewTask As Task
Dim i As Integer = 0
Do Until Items(i) Is Nothing
NewTask =
CurrentProject.Tasks.Item(CurrentProject.Tasks.Count)
NewTask.Name = Items(i).Name
NewTask.Notes = Items(i).Notes
CurrentProject.Tasks.Add(NewTask)
i += 1
Loop
(System / Software Config):
Windows 2k SP4
Visual Studio 2003 Pro
MS Project 2003 Standard
It's probably something silly that I've missed, but any help would be
greatly received.
Thanks in advance,
Duncan