From VBA scroll to specific ID or Unique ID regardless of view

G

Gary

I have MS Project VBA application that at one point asks user for Unique ID
or ID and then I want application to scroll to this task so that it appears
at top of display.

When I use “SelectTaskField Row:= ID, Column:="Name", RowRelative:=false†it
doesn’t always show the ID I’m expecting at top of display. I understand ID
number is view specific, but if I don’t change view why can’t this work ?

I can also easily get the Unique ID and find its row number in current view
but that doesn’t display correct ID at top of display either.

Any ideas ?

Thanks,

Gary
 
J

Jack Dahlgren MVP

Project scrolling is not that reliable. There is not much you can do about
it.

-Jack Dahlgren
 
J

John

Gary said:
I have MS Project VBA application that at one point asks user for Unique ID
or ID and then I want application to scroll to this task so that it appears
at top of display.

When I use “SelectTaskField Row:= ID, Column:="Name", RowRelative:=false†it
doesn’t always show the ID I’m expecting at top of display. I understand ID
number is view specific, but if I don’t change view why can’t this work ?

I can also easily get the Unique ID and find its row number in current view
but that doesn’t display correct ID at top of display either.

Any ideas ?

Thanks,

Gary

Gary,
The main problem with any of the foreground processing commands, (e.g.
"select" type commands), is that they take action on what is currently
displayed. As you found out, the "row" argument for the SelectTaskField
Method is the display row, not necessarily the task ID. As long as the
project is not filtered, sorted or collapsed, then the row will be the
task ID, but this may not always be the case when a user is working on a
project file.

Attempting to "scroll" the display so the desired ID is at the top is
neither easy nor apparently reliable, according to Jack. However, if all
you really want to do is to jump to the desired task, you might find the
following code useful:
Sub gototest()
On Error Resume Next
EditGoTo ID:=[the desired task ID]
If Err > 0 Then
MsgBox "this task isn't available in the current view structure"
Else
End If
On Error GoTo 0
End Sub

If the project is filtered or collapsed the user will be told with
something other than an evil runtime error message.

John
Project MVP
 
G

Gary

John said:
Gary said:
I have MS Project VBA application that at one point asks user for Unique ID
or ID and then I want application to scroll to this task so that it appears
at top of display.

When I use “SelectTaskField Row:= ID, Column:="Name", RowRelative:=false†it
doesn’t always show the ID I’m expecting at top of display. I understand ID
number is view specific, but if I don’t change view why can’t this work ?

I can also easily get the Unique ID and find its row number in current view
but that doesn’t display correct ID at top of display either.

Any ideas ?

Thanks,

Gary

Gary,
The main problem with any of the foreground processing commands, (e.g.
"select" type commands), is that they take action on what is currently
displayed. As you found out, the "row" argument for the SelectTaskField
Method is the display row, not necessarily the task ID. As long as the
project is not filtered, sorted or collapsed, then the row will be the
task ID, but this may not always be the case when a user is working on a
project file.

Attempting to "scroll" the display so the desired ID is at the top is
neither easy nor apparently reliable, according to Jack. However, if all
you really want to do is to jump to the desired task, you might find the
following code useful:
Sub gototest()
On Error Resume Next
EditGoTo ID:=[the desired task ID]
If Err > 0 Then
MsgBox "this task isn't available in the current view structure"
Else
End If
On Error GoTo 0
End Sub

If the project is filtered or collapsed the user will be told with
something other than an evil runtime error message.

John
Project MVP
.
John,

That makes sense.

Thanks,

Gary
 
J

John

Gary said:
John said:
Gary said:
I have MS Project VBA application that at one point asks user for Unique
ID
or ID and then I want application to scroll to this task so that it
appears
at top of display.

When I use ⤦SelectTaskField Row:= ID, Column:="Name",
RowRelative:=falseâ¤ù it
doesnâ¤t always show the ID Iâ¤m expecting at top of display. I
understand ID
number is view specific, but if I donâ¤t change view why canâ¤t this
work ?

I can also easily get the Unique ID and find its row number in current
view
but that doesnâ¤t display correct ID at top of display either.

Any ideas ?

Thanks,

Gary

Gary,
The main problem with any of the foreground processing commands, (e.g.
"select" type commands), is that they take action on what is currently
displayed. As you found out, the "row" argument for the SelectTaskField
Method is the display row, not necessarily the task ID. As long as the
project is not filtered, sorted or collapsed, then the row will be the
task ID, but this may not always be the case when a user is working on a
project file.

Attempting to "scroll" the display so the desired ID is at the top is
neither easy nor apparently reliable, according to Jack. However, if all
you really want to do is to jump to the desired task, you might find the
following code useful:
Sub gototest()
On Error Resume Next
EditGoTo ID:=[the desired task ID]
If Err > 0 Then
MsgBox "this task isn't available in the current view structure"
Else
End If
On Error GoTo 0
End Sub

If the project is filtered or collapsed the user will be told with
something other than an evil runtime error message.

John
Project MVP
.
John,

That makes sense.

Thanks,

Gary

Gary,
You're welcome.
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