Trying to toggle Tools/Options/View/Show Summary Tasks

G

G Lykos

Greetings! Am stuck trying to create a macro to toggle the captioned switch
to facilitate switching summary task suppression on/off. Macro recording
for demand value is simple: OptionsView DisplaySummaryTasks:= False.
However, I have been unable to figure out how to read the current value of
Boolean property (?) DisplaySummaryTasks so as to set it equal to NOT it.

Would appreciate help in figuring out how to read the current value, and/or
another way to accomplish this. Also, is there a way to create a toolbar
button and then assign the macro to it?

Thanks!
George
 
J

John

G Lykos said:
Greetings! Am stuck trying to create a macro to toggle the captioned switch
to facilitate switching summary task suppression on/off. Macro recording
for demand value is simple: OptionsView DisplaySummaryTasks:= False.
However, I have been unable to figure out how to read the current value of
Boolean property (?) DisplaySummaryTasks so as to set it equal to NOT it.

Would appreciate help in figuring out how to read the current value, and/or
another way to accomplish this. Also, is there a way to create a toolbar
button and then assign the macro to it?

Thanks!
George

George,
For you first question, use the OptionsView Method. It will allow you to
set (or clear) the Project Summary option (along with many others).
Check the VBA help file for syntax details.

As far as creating a toolbar button and assigning a macro here are the
instructions I give people when I create a macro for them:

For convenience you may want to attach the macro to a custom toolbar
button. If you have never done that before, here are the instructions:
14. RIght click on a blank area of toolbars to bring up the "Customize"
window.
15. Select the Toolbars tab and hit "New".
16. Give your toolbar a name and hit "OK". A small toolbar box will
appear somewhere on your screen. Drag the box to a blank area with the
other toolbars.
17. Select the Commands tab on the "Customize" window. and scroll down
to "All macros" in the Categories selection list on the left.
18. Select "All macros" and scroll down the list of macros on the right
side to the macro [your macro name here] and select it. (Note: Depending
on where the macro resides there may be more than one version - one
attached to a specific file and the other resident in your Global.
Normally you want to assign the toolbar button to the one in your
Global.)
19. Select [your macro name here] and drag it to the new toolbar.
20. Close the "Customize" window. The custom toolbar button will be
saved with your Global when you quit Project.

Hope this helps.
John
 
G

G Lykos

John, thanks for your reply. Took another look at OptionsView method -
don't think it's going to help. If you look at the Tools/Options/View
dialog box, you'll notice that Show Summary Tasks is different than Project
Summary. Project Summary can be accessed very directly - Show Summary Tasks
(AKA DisplaySummaryTasks for write-only operations, as far as I can tell) is
a different animal. What's curious is that FilterEdit happens to have a
write-only ShowSummaryTasks argument, making me wonder about the internal
mechanics of Options/View/Show Summary Tasks - is it executed as a filter?

Anyhow, this leaves me still looking for a way to read the Boolean status of
the Show Summary Tasks checkbox in Tools/Options/View. Further thoughts?

Thanks,
George


John said:
G Lykos said:
Greetings! Am stuck trying to create a macro to toggle the captioned switch
to facilitate switching summary task suppression on/off. Macro recording
for demand value is simple: OptionsView DisplaySummaryTasks:= False.
However, I have been unable to figure out how to read the current value of
Boolean property (?) DisplaySummaryTasks so as to set it equal to NOT it.

Would appreciate help in figuring out how to read the current value, and/or
another way to accomplish this. Also, is there a way to create a toolbar
button and then assign the macro to it?

Thanks!
George

George,
For you first question, use the OptionsView Method. It will allow you to
set (or clear) the Project Summary option (along with many others).
Check the VBA help file for syntax details.

As far as creating a toolbar button and assigning a macro here are the
instructions I give people when I create a macro for them:

For convenience you may want to attach the macro to a custom toolbar
button. If you have never done that before, here are the instructions:
14. RIght click on a blank area of toolbars to bring up the "Customize"
window.
15. Select the Toolbars tab and hit "New".
16. Give your toolbar a name and hit "OK". A small toolbar box will
appear somewhere on your screen. Drag the box to a blank area with the
other toolbars.
17. Select the Commands tab on the "Customize" window. and scroll down
to "All macros" in the Categories selection list on the left.
18. Select "All macros" and scroll down the list of macros on the right
side to the macro [your macro name here] and select it. (Note: Depending
on where the macro resides there may be more than one version - one
attached to a specific file and the other resident in your Global.
Normally you want to assign the toolbar button to the one in your
Global.)
19. Select [your macro name here] and drag it to the new toolbar.
20. Close the "Customize" window. The custom toolbar button will be
saved with your Global when you quit Project.

Hope this helps.
John
 
J

John

G Lykos said:
John, thanks for your reply. Took another look at OptionsView method -
don't think it's going to help. If you look at the Tools/Options/View
dialog box, you'll notice that Show Summary Tasks is different than Project
Summary. Project Summary can be accessed very directly - Show Summary Tasks
(AKA DisplaySummaryTasks for write-only operations, as far as I can tell) is
a different animal. What's curious is that FilterEdit happens to have a
write-only ShowSummaryTasks argument, making me wonder about the internal
mechanics of Options/View/Show Summary Tasks - is it executed as a filter?

Anyhow, this leaves me still looking for a way to read the Boolean status of
the Show Summary Tasks checkbox in Tools/Options/View. Further thoughts?

Thanks,
George


George,
Sorry, I didn't pay close enough attention to what you were asking. I
should have told you to use the DisplayProjectSummaryTask Property. It
is a read/write boolean property of the Active Project.

With regard to whether Options/View/Show Summary Tasks is executed as a
filter, it may be but what difference does it make? The underlying data
in Project, whether it is basic data (i.e. Task Name, Start,
Predecessors, etc.) or calculated (i.e. Summary Line data), is stored in
3 database sections - one for task data, one for resource data and one
for assignment data. What a user sees in a view is in effect "filtered"
data from one or more of those databases.

Hope this helps.
John
 
G

G Lykos

John, thanks, but not sure we connected yet. Project Summary Task and
Summary Tasks are two different things. Yes, the Project Summary Task value
is easily read and written via DisplayProjectSummaryTask. Summary Tasks,
however, is different, pertaining to ALL summary tasks, not just the
top-level Project Summary Task toggled as task 0.

Summary tasks can be turned off and on using OptionsView
DisplaySummaryTasks:= False or True. However, the question remains: How do
you read the current setting, corresponding to the Options/View/Show Summary
Tasks checkbox that controls this (and not the Project Summary Task
checkbox, which is subordinate to it in the same dialog box)? Put
differently: DisplaySummaryTasks is a named argument to method OptionsView,
and I have been unsuccessful in figuring out a way to read it as a property.

Thanks for your patience in sorting this out.
George
 
J

John

G Lykos said:
John, thanks, but not sure we connected yet. Project Summary Task and
Summary Tasks are two different things. Yes, the Project Summary Task value
is easily read and written via DisplayProjectSummaryTask. Summary Tasks,
however, is different, pertaining to ALL summary tasks, not just the
top-level Project Summary Task toggled as task 0.

Summary tasks can be turned off and on using OptionsView
DisplaySummaryTasks:= False or True. However, the question remains: How do
you read the current setting, corresponding to the Options/View/Show Summary
Tasks checkbox that controls this (and not the Project Summary Task
checkbox, which is subordinate to it in the same dialog box)? Put
differently: DisplaySummaryTasks is a named argument to method OptionsView,
and I have been unsuccessful in figuring out a way to read it as a property.

Thanks for your patience in sorting this out.
George
George,
Ok, I think my bulb finally went on (boing!). You want to READ the
setting of Options/View/Show Summary, right? Ordinarily the answer would
be, sorry, no can do, but sometimes you gotta step outside the box to
get what you want. This is a case similar to telling what font color a
Task Name is using. There is no direct method so an indirect method must
be used. In the case of the Summary Lines we know that they are at
Outline Level 1. Therefore, if you test for that Outline Level and don't
find it, you will know that Summary Lines are not shown.

Sorry for the misunderstanding. Hope this helps.
John
 
G

G Lykos

Okay, John, I think we're on the right track now. However, I need a little
more guidance, please.

First, a task which is not a summary can exist at Outline Level 1, so
something else is needed to test (if I understood your suggestion
correctly). However, I understand about needing to take an oblique approach
because the DisplaySummaryTasks property isn't available externally
(although it sure seems like something pretty basic, that should be
accessible).

So, I wrote a loop to cycle through the tasks collected using
ActiveProject.Tasks and test for Task_.Summary being True (signifying that a
particular task is a summary). However, this collection has every task
regardless of whether or not it's visible in the view. I tried out a filter
to see if it behaves differently, and it doesn't - every task is in the
collection, regardless of what's displayed through the filter. How then do
I isolate only the tasks that are visible in a particular view (such as when
Show Summary Tasks is turned on or off) for testing?

Thanks,
George
 
J

John

G Lykos said:
Okay, John, I think we're on the right track now. However, I need a little
more guidance, please.

First, a task which is not a summary can exist at Outline Level 1, so
something else is needed to test (if I understood your suggestion
correctly). However, I understand about needing to take an oblique approach
because the DisplaySummaryTasks property isn't available externally
(although it sure seems like something pretty basic, that should be
accessible).

So, I wrote a loop to cycle through the tasks collected using
ActiveProject.Tasks and test for Task_.Summary being True (signifying that a
particular task is a summary). However, this collection has every task
regardless of whether or not it's visible in the view. I tried out a filter
to see if it behaves differently, and it doesn't - every task is in the
collection, regardless of what's displayed through the filter. How then do
I isolate only the tasks that are visible in a particular view (such as when
Show Summary Tasks is turned on or off) for testing?

Thanks,
George

George,
Yes you are correct. I realized that several hours after I posted my
last answer. Every file I work with starts with a Summary Line and I
don't mean the Project Summary Line so I sorta assumed. . . Bad
assumption.

No problem, my point is that sometimes you have to approach things
indirectly and you picked up on that. It's just that my example wasn't
that great. The following code will do what you need. You can convert it
to a function if you like and include it in whatever other code you are
using.

Sub OptViewSum_State()
FilterApply Name:="summary tasks"
SelectTaskColumn
On Error Resume Next
Set Area = ActiveSelection.Tasks
If Err <> 0 Then
MsgBox "Option to show Summary Lines is: ""Off""", vbInformation
Else
MsgBox "Option to show Summary Lines is: ""On""", vbInformation
End If
On Error GoTo 0
FilterApply Name:="all Tasks"

End Sub

John
Project MVP
 
J

Jan De Messemaeker

Hi,

SummOn=false
filterapply "all tasks"
selectall
for each anytask in activeselection.tasks
if not anytask is nothing then
summon=summon or anytask.summary
end if
next anytask

HTH
 
G

G Lykos

Thanks, John - I'll give it a shot.

Please allow me to ask again for clarification of a related question that
has come up before - how using VBA do I identify (only) the tasks that are
visible in a particular view?

Thanks again,
George
 
J

Jan De Messemaeker

Hi George,
My alternative implicitly repliest this one doesn't it?
Select all
activeselection.tasks
HTH
 
J

John

G Lykos said:
Thanks, John - I'll give it a shot.

Please allow me to ask again for clarification of a related question that
has come up before - how using VBA do I identify (only) the tasks that are
visible in a particular view?

Thanks again,
George

George,
I think Jan answered the question but let me expand. As you found out
using a syntax such as, "For each t in ActiveProject.Tasks" will loop
through all tasks in a project regardless of whether they are visible in
the view or not. This is one of the advantages of background processing
- it is independent of the view.

On the other hand, there are times when you only need or want to look at
a specific group of project objects. Jan's use of "SelectAll" and my use
of "SelectTaskColumn" will create a current selection of project objects
on which to operate (filtered, sorted, or otherwise modified). Although
background processing is faster and more efficient, it is sometimes
necessary to select certain elements and execute part of the code using
foreground processing.

Jan's approach was simple but requires running through all tasks in the
selection to determine the final answer. My approach was more complex
but didn't require looping through any tasks. Both approaches work, it
is just a matter of choice.

Hope this helps.
John
 
G

G Lykos

Okay, John, got it working. A key (undocumented? or where did I miss it?)
feature of SelectXXX is that it operates on those tasks visible in the
current view (did I say that right?), not all tasks in the project. A last
question (at least until the next one) - when I'm through with the
selection, how do I unselect it?

Thanks,
George
 
G

G Lykos

John, put the macro in a toolbar - thanks. Now, how do I go about assigning
an icon to it?

Thanks,
George


John said:
G Lykos said:
Greetings! Am stuck trying to create a macro to toggle the captioned switch
to facilitate switching summary task suppression on/off. Macro recording
for demand value is simple: OptionsView DisplaySummaryTasks:= False.
However, I have been unable to figure out how to read the current value of
Boolean property (?) DisplaySummaryTasks so as to set it equal to NOT it.

Would appreciate help in figuring out how to read the current value, and/or
another way to accomplish this. Also, is there a way to create a toolbar
button and then assign the macro to it?

Thanks!
George

George,
For you first question, use the OptionsView Method. It will allow you to
set (or clear) the Project Summary option (along with many others).
Check the VBA help file for syntax details.

As far as creating a toolbar button and assigning a macro here are the
instructions I give people when I create a macro for them:

For convenience you may want to attach the macro to a custom toolbar
button. If you have never done that before, here are the instructions:
14. RIght click on a blank area of toolbars to bring up the "Customize"
window.
15. Select the Toolbars tab and hit "New".
16. Give your toolbar a name and hit "OK". A small toolbar box will
appear somewhere on your screen. Drag the box to a blank area with the
other toolbars.
17. Select the Commands tab on the "Customize" window. and scroll down
to "All macros" in the Categories selection list on the left.
18. Select "All macros" and scroll down the list of macros on the right
side to the macro [your macro name here] and select it. (Note: Depending
on where the macro resides there may be more than one version - one
attached to a specific file and the other resident in your Global.
Normally you want to assign the toolbar button to the one in your
Global.)
19. Select [your macro name here] and drag it to the new toolbar.
20. Close the "Customize" window. The custom toolbar button will be
saved with your Global when you quit Project.

Hope this helps.
John
 
J

John

G Lykos said:
Okay, John, got it working. A key (undocumented? or where did I miss it?)
feature of SelectXXX is that it operates on those tasks visible in the
current view (did I say that right?), not all tasks in the project. A last
question (at least until the next one) - when I'm through with the
selection, how do I unselect it?

Thanks,
George
George,
All the "Select" type methods are documented in the VBA help file, but I
admit it isn't always easy to find what you think you are looking for
(did I say that right?).

Depending on what you need to do next in the code, selected objects
don't necessarily have to be de-selected. For example, if the next part
of the code you are writing operates in background processing (e.g. "For
Each t in ActiveProject.Tasks"), it doesn't matter whether the current
view has selected objects or not. However to answer your question, I
generally use the "SelectBeginning" Method. It selects the first cell in
the active view table which is basically what you have when you first
open a file.

Hope this helps.
John
 
G

G Lykos

John, please disregard - already fumbled my way through it. Thanks, George


G Lykos said:
John, put the macro in a toolbar - thanks. Now, how do I go about assigning
an icon to it?

Thanks,
George


value
of
Boolean property (?) DisplaySummaryTasks so as to set it equal to NOT it.

Would appreciate help in figuring out how to read the current value, and/or
another way to accomplish this. Also, is there a way to create a toolbar
button and then assign the macro to it?

Thanks!
George

George,
For you first question, use the OptionsView Method. It will allow you to
set (or clear) the Project Summary option (along with many others).
Check the VBA help file for syntax details.

As far as creating a toolbar button and assigning a macro here are the
instructions I give people when I create a macro for them:

For convenience you may want to attach the macro to a custom toolbar
button. If you have never done that before, here are the instructions:
14. RIght click on a blank area of toolbars to bring up the "Customize"
window.
15. Select the Toolbars tab and hit "New".
16. Give your toolbar a name and hit "OK". A small toolbar box will
appear somewhere on your screen. Drag the box to a blank area with the
other toolbars.
17. Select the Commands tab on the "Customize" window. and scroll down
to "All macros" in the Categories selection list on the left.
18. Select "All macros" and scroll down the list of macros on the right
side to the macro [your macro name here] and select it. (Note: Depending
on where the macro resides there may be more than one version - one
attached to a specific file and the other resident in your Global.
Normally you want to assign the toolbar button to the one in your
Global.)
19. Select [your macro name here] and drag it to the new toolbar.
20. Close the "Customize" window. The custom toolbar button will be
saved with your Global when you quit Project.

Hope this helps.
John
 

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