Automate the copying of tasks from one Project file to another

J

Jason

Hoping someone can help here. I have to create a series of project files for
repetative projects based off of one master Project Template. The master
Templete is a .mpp file and contains any and all tasks that my other project
could have in them. What I was hoping to do was create an interface
(thinking combo box) that I can put in the tool bar of the Global file so
when I open a new .mpp file I can then just select tasks from the drop down
list and they will populate into my new file. I could then just select the
tasks I want (hoping to just select high level summary tasks and have all
subtasks come with) and modify from there.

To do this I figure I need to create a Combo Box, populate it with the
summary tasks from the Master Project and then once one is seleced copy/past
it into the new file, probably at the current cursor location. Is this
possible? Is there a better way?

The code I have thus far is below, where I am stuck is in populating the
Combo Box with the Summary task names.

Any thoughts would be appreciated.

Dim Counter As Integer
Dim Tsk As Task

Counter = 0

With ComboBox1
ColumnCount = 1
ColumnWidths = 75
AutoSize = True
Height = 15
ListRows = ActiveProject.Tasks.Count
End With

For Each Tsk In ActiveProject.Tasks
If Not Tsk Is Nothing Then
If Tsk.Summary = True Then
XX ComboBox1.AddItem Tsk.Name
Counter = Counter + 1
End If
End If
Next Tsk

End Sub
 
J

Jason

Jan,

The Error is:
Run Time Error 424
Object Required

And the line highlighted is the ComboBox.AddIten Tsk.Name line that I put
the XX before below.

I have a Debug.Print Tsk.Name line ahead of it to hele me see what is going
on and it prints the first summary task to the Immediate Box, but jsut the
first one so when it is failing it is the first time through the loop.

Am I even taking the correct approach on this? I an new to VBA so if there
is a better way to do this I am open.

Thanks
Jason
 
J

Jan De Messemaeker

Hi,

Did you create a combobox1 at all?
better is to start the instructions with Load Combobox1
And BTW, after with Combobox1
the following statements should start with a period . fi.
..height=15

Hope this helps,

--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
+32 495 300 620
For availability check:
http://users.online.be/prom-ade/Calendar.pdf
 
J

Jason

Jan,

I think I created a ComboBox1, in the Forms floder of my Global.mpt file I
have a item called ComboBox1 and when I open it shows the grid view and it is
a combo box.

I tried your change and replaced the With ComboBox1 code I had with:

Load ComboBox1.

Now I am getting a different error, this one is Complie Error, Method or
Object not found and the .AddItem in the same line is now highlighted.

Thanks
Jason
 
J

Jan De Messemaeker

Hi,

Sorry, I haven't been very clear in my thoughts.
There are two objects you need.
You need a form, and in the form a control.
Start over.
Insert a form, call it CbForm (preferrably not combobox because that one
will be inserted into it)
Show the toolbox
Drag the combobox symbol into the form to create one.
Call it ComboBox1

Now the code will look like this

Counter = 0
Load Cbform

With Cbform.ComboBox1
..ColumnCount = 1
..ColumnWidths = 75
..AutoSize = True
..Height = 15
End With

For Each Tsk In ActiveProject.Tasks
If Not Tsk Is Nothing Then
If Tsk.Summary = True Then
CbForm.ComboBox1.AddItem Tsk.Name
Counter = Counter + 1
End If
End If
Next Tsk


When the code is inside the form you can address combobox1 directly.

Hope this helps,


--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
+32 495 300 620
For availability check:
http://users.online.be/prom-ade/Calendar.pdf
 

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