Hello KSwan.....
You're in luck! Yes, there is a way to do exactly what you want, and here
is the function I wrote to give me the screen type of all of the available
screens. You can do this in a single line of code within the function.
First, create a variable to receive the value returned by the function.
This function allows you to pass the name of any view to it, and if it's in
the project schedule, return the type of screen upon which the view is based.
"WhichView" is the name of the view you want to evaluate.
The following example sends the name of the currently displayed view to the
function, which then returns the type of screen to your variable.
************************************************************
'Define a variable to store the value returned by the function.
Dim sScreenType as string
'Call the vScreen function, send the name of the currently displayed view
to vScreen, and then store the "Screen Type" returned by vScreen in the
variable called sScreenType.
sScreenType = vScreen(ActiveProject.CurrentView)
Function vScreen(WhichView As String) As String
'pjviewscreen types =
'pjGantt '1
'pjNetworkDiagram '2
'pjRelationshipDiagram '3
'pjTaskForm '4
'pjTaskSheet '5
'pjResourceForm '6
'pjResourceSheet '7
'pjResourceGraph '8
'pjTaskDetailsForm '10
'pjTaskNameForm '11
'pjResourceNameForm '12
'pjCalendar '13
'pjTaskUsage '14
'pjResourceUsage '15
vScreen = Choose(ActiveProject.Views(WhichView).Screen, "Gantt", "Network",
"Relationship", "Task Form", _
"Task Sheet", "Resource Form", "Resource
Sheet", _
"Resource Graph", "", "Task Details",
"Task Name", _
"Resource Name", "Calendar", "Task Usage",
"Resource Usage")
Exit Function
End Function
************************************************************
How it works:
"ActiveProject.Views(WhichView).Screen" is the syntax that accesses the
"Screen" propery in the collection of views in the Active Project.
"WhichView" specifies which view within the collection of views from which to
read the Screen property.
The Screen value returned is the pjScreen constant = to one of the pj values
I listed above. The "Choose" operation selects a meaningful description of
the Screen Type from the list of choices I provided (that you can change to
anything you want).
Using this function, vScreen(ActiveProject.CurrentView) of a Gantt view
returns "Gantt". vScreen(ActiveProject.CurrentView) of a Network Diagram
returns "Network"
*************************************************************
Gary Phillips, PMP, SM&A Consulting. Real answers for real people.