Inserted Projects and External Links

R

RC

Hello, I thought I had figured out my problem this past weekend with
other helpful posts I found on this forum. I hope that I can have a
little more guidance.

I have a macro that exports timescaled data to excel. It also needs to
work for schedules with inserted projects, schedules with external
tasks, or a master project (consisting of only subprojects). I found
an earlier very helpful post that covers the bases if the macro is run
on a Task view (using OutlineShowTasks expaninsertedprojects:=True).
However, as this macro needs to be distributed to others, I am hoping
there is a method that I can use that does not need a Task view. Is
this possible?

Thanks for any help,

RC
 
J

John

RC said:
Hello, I thought I had figured out my problem this past weekend with
other helpful posts I found on this forum. I hope that I can have a
little more guidance.

I have a macro that exports timescaled data to excel. It also needs to
work for schedules with inserted projects, schedules with external
tasks, or a master project (consisting of only subprojects). I found
an earlier very helpful post that covers the bases if the macro is run
on a Task view (using OutlineShowTasks expaninsertedprojects:=True).
However, as this macro needs to be distributed to others, I am hoping
there is a method that I can use that does not need a Task view. Is
this possible?

Thanks for any help,

RC

RC,
It sounds like the OutlineShowTasks expandinsertedprojects:=True might
have came from one of my responses.

Why does distributing the macro to others preclude using a task view? In
all the macros I write I always use background processing which doesn't
require that any particular view be active. Only in certain
circumstances do I command a particular view, (e.g. when setting a
filter to provide a selected set of tasks for processing). Then when the
code no longer needs that particular view, it resets the file to the
original view.

The OutlineShowTasks is a method that applies to the application level
and I don't think it requires any particular view to be active for the
method to be successful.

John
Project MVP
 
R

RC

RC,
It sounds like the OutlineShowTasks expandinsertedprojects:=True might
have came from one of my responses.

Why does distributing the macro to others preclude using a task view? In
all the macros I write I always use background processing which doesn't
require that any particular view be active. Only in certain
circumstances do I command a particular view, (e.g. when setting a
filter to provide a selected set of tasks for processing). Then when the
code no longer needs that particular view, it resets the file to the
original view.

The OutlineShowTasks is a method that applies to the application level
and I don't think it requires any particular view to be active for the
method to be successful.

John
Project MVP

Hello John!

Maybe I'm not doing something right. I tested the OutlineShowTasks
method (thank you for that!) and it did not work unless I had run the
macro on a Task view. I get a "Run time error 1100 The Command is not
available in this situation" with debugger highlighting code at the
line OutlineShowTasks expandinsertedprojects:=True. I've found that it
is no problem when I start the macro on a Task view however. Is there
something perhaps that I'm missing? I believe you are right, I am
using code from your previous post:
OutlineShowTasks expandinsertedprojects:=True
SelectTaskColumn
Set Area = ActiveSelection.Tasks
For Each t In Area

Thank you,

RC
 
J

Jack Dahlgren

I would expect that outllineshowtasks would only work in a task view as it
is related to display. I guess the question really is can you do what you
want without using it? Typically to open subprojects I would use the
subprojects collection

for each subproject in activeproject.subprojects
myPath = subproject.path

then use the fileopen using that path to open the subproject. You can then
do whatever you want within that subproject
It has been a while, but I think it is also wise to set a variable which
refers to your master project so you can return to it.
set myMaster = activeproject
would work when you are in the master project, then you can return by using
something like myMaster.Activate

I'm typing this code off the top of my head without testing so the syntax
may vary slightly.

-Jack Dahlgren
 
J

John

RC said:
Hello John!

Maybe I'm not doing something right. I tested the OutlineShowTasks
method (thank you for that!) and it did not work unless I had run the
macro on a Task view. I get a "Run time error 1100 The Command is not
available in this situation" with debugger highlighting code at the
line OutlineShowTasks expandinsertedprojects:=True. I've found that it
is no problem when I start the macro on a Task view however. Is there
something perhaps that I'm missing? I believe you are right, I am
using code from your previous post:
OutlineShowTasks expandinsertedprojects:=True
SelectTaskColumn
Set Area = ActiveSelection.Tasks
For Each t In Area

Thank you,

RC

RC,
I think Jack is right about the OutlineShowTasks method only working
with a task view. To be honest, I use the sequence of steps noted on all
macros that work with dynamic masters. As I said previously, it doesn't
matter what view the file opens in because I set the view in code if I
need something specific. Just before the macro completes, I return the
view to whatever it was when the file was opened. That way the user
doesn't have to worry about "losing" their view.

On the surface it looks like Jack's approach would also work. It is a
little more complex keeping track of which project is the active
project, but you could try it. I'd say use whichever approach works best
for you.

John
Project MVP
 
R

RC

RC,
I think Jack is right about the OutlineShowTasks method only working
with a task view. To be honest, I use the sequence of steps noted on all
macros that work with dynamic masters. As I said previously, it doesn't
matter what view the file opens in because I set the view in code if I
need something specific. Just before the macro completes, I return the
view to whatever it was when the file was opened. That way the user
doesn't have to worry about "losing" their view.

On the surface it looks like Jack's approach would also work. It is a
little more complex keeping track of which project is the active
project, but you could try it. I'd say use whichever approach works best
for you.

John
Project MVP

Hi John,

Thank you for that insight! (It never entered my thoughts once; I was
stumped.) I used the below to switch to a Task View and am able to
follow the method that you suggested in your previous post.

Sub ChangeToGantt()
ViewApply Name:="Gantt Chart", SinglePane:=True
End Sub

I've _almost_ got it to work now. I just have one more remaining error
with the Resource fields with the inserted projects, and that should
be it!

Thanks again,

RC
 
R

RC

I would expect that outllineshowtasks would only work in a task view as it
is related to display. I guess the question really is can you do what you
want without using it? Typically to open subprojects I would use the
subprojects collection

for each subproject in activeproject.subprojects
myPath = subproject.path

then use the fileopen using that path to open the subproject. You can then
do whatever you want within that subproject
It has been a while, but I think it is also wise to set a variable which
refers to your master project so you can return to it.
set myMaster = activeproject
would work when you are in the master project, then you can return by using
something like myMaster.Activate

I'm typing this code off the top of my head without testing so the syntax
may vary slightly.

-Jack Dahlgren

Hi Jack,

Thank you for the suggestion! I was able to implement your suggestion
also, but I admit that it was difficult for me to keep up keeping
track of which project was active. I'm going to keep on working your
suggestion to make it work - that's how I'll learn to be better at
this.

RC
 
J

John

RC,
I think Jack is right about the OutlineShowTasks method only working
with a task view. To be honest, I use the sequence of steps noted on all
macros that work with dynamic masters. As I said previously, it doesn't
matter what view the file opens in because I set the view in code if I
need something specific. Just before the macro completes, I return the
view to whatever it was when the file was opened. That way the user
doesn't have to worry about "losing" their view.

On the surface it looks like Jack's approach would also work. It is a
little more complex keeping track of which project is the active
project, but you could try it. I'd say use whichever approach works best
for you.

John
Project MVP

Hi John,

Thank you for that insight! (It never entered my thoughts once; I was
stumped.) I used the below to switch to a Task View and am able to
follow the method that you suggested in your previous post.

Sub ChangeToGantt()
ViewApply Name:="Gantt Chart", SinglePane:=True
End Sub

I've _almost_ got it to work now. I just have one more remaining error
with the Resource fields with the inserted projects, and that should
be it!

Thanks again,

RC[/QUOTE]

RC,
You're welcome and thanks for the feedback.

John
Project MVP
 
J

Jack Dahlgren

RC,

I'd just use a couple of variables:

dim mProj as Project
dim sProj as Project

When you open the master
set mProj = ActiveProject

From there you can assign sProj in turn to the different subprojects
You do not need a project to be "active" to work with it.
For example you can use code such as

for each task in sProj
'do stuff
next task

even if the master project is the one on the screen (assuming you aren't
doing formatting etc.)
I think that using variables is easier than keeping track of which project
is active, but I tend to use activeproject as I had such bad experiences
with interproject dependencies back in 1998... I'm still scarred.
-Jack
 

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