A small macro question

A

assaf1978

Hi,
I've written a macro that will automatically check one value of a cell and
according to it will change a value of another cell.
I ran into a problem when I wanted to move between two files (a master gantt
file). Is there a VBA function that enables MS-Project to be able to move
from a cell in one file to a cell in another file? or maybe I can hyperlink
two activities from two different files?

Thanks,
Assaf.
 
J

John

assaf1978 said:
Hi,
I've written a macro that will automatically check one value of a cell and
according to it will change a value of another cell.
I ran into a problem when I wanted to move between two files (a master gantt
file). Is there a VBA function that enables MS-Project to be able to move
from a cell in one file to a cell in another file? or maybe I can hyperlink
two activities from two different files?

Thanks,
Assaf.

assaf1978,
You need to understand that in a consolidated master, the subproject
files are not actually part of the master. The master only contains
pointers to the actual subproject file. Consequently if you try to loop
through the tasks of the master you will only see the tasks that
actually belong to the master,if any, and the insertion point summary
lines of each subproject.

What you need to do is to reference each subproject's objects. The basic
syntax is:
ActiveProject.Subprojects(index).SourceProject.[object/property]

For example, let's say you want the task name of the 3rd task in
subproject "1". The syntax would be:
ActiveProject.Subprojects(1).SourceProject.Tasks(3).Name

Hope this helps.

John
Project MVP
 
A

assaf1978

Hi John,
That's all very good, but I depend on the predecessor field. In it there's a
direct link to the subproject. Is there a way to follow that link using VBA?

John said:
assaf1978 said:
Hi,
I've written a macro that will automatically check one value of a cell and
according to it will change a value of another cell.
I ran into a problem when I wanted to move between two files (a master gantt
file). Is there a VBA function that enables MS-Project to be able to move
from a cell in one file to a cell in another file? or maybe I can hyperlink
two activities from two different files?

Thanks,
Assaf.

assaf1978,
You need to understand that in a consolidated master, the subproject
files are not actually part of the master. The master only contains
pointers to the actual subproject file. Consequently if you try to loop
through the tasks of the master you will only see the tasks that
actually belong to the master,if any, and the insertion point summary
lines of each subproject.

What you need to do is to reference each subproject's objects. The basic
syntax is:
ActiveProject.Subprojects(index).SourceProject.[object/property]

For example, let's say you want the task name of the 3rd task in
subproject "1". The syntax would be:
ActiveProject.Subprojects(1).SourceProject.Tasks(3).Name

Hope this helps.

John
Project MVP
 
J

Jack Dahlgren

Yes, you need to open the subproject and find the corresponding task in the
subproject.

-Jack Dahlgren


assaf1978 said:
Hi John,
That's all very good, but I depend on the predecessor field. In it there's
a
direct link to the subproject. Is there a way to follow that link using
VBA?

John said:
assaf1978 said:
Hi,
I've written a macro that will automatically check one value of a cell
and
according to it will change a value of another cell.
I ran into a problem when I wanted to move between two files (a master
gantt
file). Is there a VBA function that enables MS-Project to be able to
move
from a cell in one file to a cell in another file? or maybe I can
hyperlink
two activities from two different files?

Thanks,
Assaf.

assaf1978,
You need to understand that in a consolidated master, the subproject
files are not actually part of the master. The master only contains
pointers to the actual subproject file. Consequently if you try to loop
through the tasks of the master you will only see the tasks that
actually belong to the master,if any, and the insertion point summary
lines of each subproject.

What you need to do is to reference each subproject's objects. The basic
syntax is:
ActiveProject.Subprojects(index).SourceProject.[object/property]

For example, let's say you want the task name of the 3rd task in
subproject "1". The syntax would be:
ActiveProject.Subprojects(1).SourceProject.Tasks(3).Name

Hope this helps.

John
Project MVP
 
J

John

assaf1978 said:
Hi John,
That's all very good, but I depend on the predecessor field. In it there's a
direct link to the subproject. Is there a way to follow that link using VBA?

assaf1987,
Yes, Jack provided one suggestion, I'll give you another. Using the same
syntax as in my previous message you could access the Predecessors field
property and then decode the string. I've used that method in a macro I
wrote a few years ago.

Or you could access the Task Dependencies collection object although I
haven't really tried using that in any macros I've written.

Hope this helps.
John
Project MVP
John said:
assaf1978 said:
Hi,
I've written a macro that will automatically check one value of a cell
and
according to it will change a value of another cell.
I ran into a problem when I wanted to move between two files (a master
gantt
file). Is there a VBA function that enables MS-Project to be able to move
from a cell in one file to a cell in another file? or maybe I can
hyperlink
two activities from two different files?

Thanks,
Assaf.

assaf1978,
You need to understand that in a consolidated master, the subproject
files are not actually part of the master. The master only contains
pointers to the actual subproject file. Consequently if you try to loop
through the tasks of the master you will only see the tasks that
actually belong to the master,if any, and the insertion point summary
lines of each subproject.

What you need to do is to reference each subproject's objects. The basic
syntax is:
ActiveProject.Subprojects(index).SourceProject.[object/property]

For example, let's say you want the task name of the 3rd task in
subproject "1". The syntax would be:
ActiveProject.Subprojects(1).SourceProject.Tasks(3).Name

Hope this helps.

John
Project MVP
 
A

assaf1978

Hi John,
I have the following predecessor for the task:
C:\Documents and Settings\a321047\My Documents\Documents\Tracking
tools\Embedded\IG XDM CPS\V7.2 4xanytrp.mpp\19

How exactly do I make the MS-Project follow that link so it would go to that
line from the master file?
I've tried evry possible variation to your suggestion but to no avail.....

Thnaks,
Assaf.
John said:
assaf1978 said:
Hi John,
That's all very good, but I depend on the predecessor field. In it there's a
direct link to the subproject. Is there a way to follow that link using VBA?

assaf1987,
Yes, Jack provided one suggestion, I'll give you another. Using the same
syntax as in my previous message you could access the Predecessors field
property and then decode the string. I've used that method in a macro I
wrote a few years ago.

Or you could access the Task Dependencies collection object although I
haven't really tried using that in any macros I've written.

Hope this helps.
John
Project MVP
John said:
Hi,
I've written a macro that will automatically check one value of a cell
and
according to it will change a value of another cell.
I ran into a problem when I wanted to move between two files (a master
gantt
file). Is there a VBA function that enables MS-Project to be able to move
from a cell in one file to a cell in another file? or maybe I can
hyperlink
two activities from two different files?

Thanks,
Assaf.

assaf1978,
You need to understand that in a consolidated master, the subproject
files are not actually part of the master. The master only contains
pointers to the actual subproject file. Consequently if you try to loop
through the tasks of the master you will only see the tasks that
actually belong to the master,if any, and the insertion point summary
lines of each subproject.

What you need to do is to reference each subproject's objects. The basic
syntax is:
ActiveProject.Subprojects(index).SourceProject.[object/property]

For example, let's say you want the task name of the 3rd task in
subproject "1". The syntax would be:
ActiveProject.Subprojects(1).SourceProject.Tasks(3).Name

Hope this helps.

John
Project MVP
 

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