copying data between two project files

W

Walter L. Skinner

In a recovery routine, I would like to be able to copy certain fields
associated with an unique id from one file to a second file with the same
unique id. In other words, loop through the first file coping the data for
that unique id to the second file record with the same unique id. The
question really is , can you have two project files open at the same time in
visual basic, referencing data in each?

Thanks for any suggestions. I am an experienced programmer, but fairly new
at visual basic.
 
J

Jan De Messemaeker

Hi,

Yes of course, Walter
One way about this is when you open them, each time create a project object:
Set TheFirstPr=Activeproject
Then when you open the second:
Set TheSecondPr=activeproject.
From there onward you can reference tasks etc. from the rpoject object:
Thefirstpr.tasks.UniqueID etc.


Alternatively, you can walk through the Projects collection to identify
them.
HTH
 
W

Walter L. Skinner

Jan:
A little more help please:
Below is the method I use to loop through the file looking for data in a task.
I am not quite sure how do I set up the code to reference the different id
numbers (loop through both files)

For example: to select the first record; get the unique id and baseline
start, then
set the same record in the second file (unique id) baseline start.

It is the referencing that I don't seem to understand. I use the t to index
through as you can see. Any help getting me going would be appreciated.

Thanks
****************************************

Dim FirstProject As Project
Dim SecondProject As Project
Dim ts As Tasks
Dim t As Task
Set FirstProject = ActiveProject
FileOpen Name:=FileName$, ReadOnly:=Not (FileRO)
'********* Open second project here
Set SecondProject = ActiveProject
For Each t In ts
....



Next t
 
J

Jan De Messemaeker

See embedded
Greetings,

--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
http://users.online.be/prom-ade/
+32-495-300 620
Walter L. Skinner said:
Jan:
A little more help please:
Below is the method I use to loop through the file looking for data in a task.
I am not quite sure how do I set up the code to reference the different id
numbers (loop through both files)

For example: to select the first record; get the unique id and baseline
start, then
set the same record in the second file (unique id) baseline start.

It is the referencing that I don't seem to understand. I use the t to index
through as you can see. Any help getting me going would be appreciated.

Thanks
****************************************

Dim FirstProject As Project
Dim SecondProject As Project
Dim ts As Tasks
Dim t As Task
Dim té as task
Dim TheUID as integer
Set FirstProject = ActiveProject
FileOpen Name:=FileName$, ReadOnly:=Not (FileRO)
'********* Open second project here
Set SecondProject = ActiveProject
For Each t In firstproject.tasks
Theuid=t.uniqueid
set t2=secondproject.tasks.uniqueid(theuid)
' Now copy from t into t2
 

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