S
Steve in Boston
I am new to MS Project VBA macros. I have set up a couple of buttons to
display various views into the project. One is called "Default View", which
will restore the project to a standard view that we use a lot. The button
and view works, but since I am new to VBA, I'm not sure if it is as efficient
as it could be, so I thought I would post it here for comment. Thank you.
Notes: The first IF statement is because I only want it to execute
button/macro for my project, or else I can't guarantee the filter and table
will be there and the macro will break. At the end, I compress the project
down level by level to Outline=2 so that when the user expands the project,
only one level at a time is expanded. Finally, I force the active cell to
the top row, second column. Any better ways to do any of this would be
appreciated.
Sub DefaultView()
' This routine restores the project view to the default view
If ActiveProject.Tasks(1).Name = "XYZ Project" Then
OutlineShowAllTasks
ViewApply Name:="Task Sheet"
TableApply Name:="_My_Default"
FilterApply Name:="All Tasks", Highlight:=False
OutlineShowTasks 5
OutlineShowTasks 4
OutlineShowTasks 3
OutlineShowTasks 2
SelectBeginning
SelectCellRight
End If
End Sub
display various views into the project. One is called "Default View", which
will restore the project to a standard view that we use a lot. The button
and view works, but since I am new to VBA, I'm not sure if it is as efficient
as it could be, so I thought I would post it here for comment. Thank you.
Notes: The first IF statement is because I only want it to execute
button/macro for my project, or else I can't guarantee the filter and table
will be there and the macro will break. At the end, I compress the project
down level by level to Outline=2 so that when the user expands the project,
only one level at a time is expanded. Finally, I force the active cell to
the top row, second column. Any better ways to do any of this would be
appreciated.
Sub DefaultView()
' This routine restores the project view to the default view
If ActiveProject.Tasks(1).Name = "XYZ Project" Then
OutlineShowAllTasks
ViewApply Name:="Task Sheet"
TableApply Name:="_My_Default"
FilterApply Name:="All Tasks", Highlight:=False
OutlineShowTasks 5
OutlineShowTasks 4
OutlineShowTasks 3
OutlineShowTasks 2
SelectBeginning
SelectCellRight
End If
End Sub