Accessing Resource Object after .Find

J

Jim Zeeb

I've encountered a problem with some code that used to work just fine.
I'm trying to access a Resource and update some of the custom fields with
data from an Excel spreadsheet.

Here is my code:

resFound = msp.Find(Field:="Name", Test:="equals", MatchCase:=False, _
Value:=Trim(lastName) & " " & Trim(firstName))
If resFound Then
AppActivate msp.projects(1).Name
Set res = msp.ActiveSelection.Resources(1)
End if

msp is the Application object for the MsProject file that is open.
res is defined as Object (for LateBinding purposes)
I have already set the view to ResourceSheet and the correct resource name
is selected.

I'm getting a 424 Object Required error.
In the Immediate window, msp.ActiveSelection.Resources.Count returns "1"

This is probably something simple, but I'm not seeing it.
I know I could loop through all the resouces looking for a match, but the
Find should be a lot quicker.

inTHANKSadvance
....jz
 
R

Rod Gill

Hi Jim,

If the code is running in Project try:
on error resume next
err.clear
set res=activeproject.resources(Trim(lastName) & " " & Trim(firstName))
if err then
'Resource not found
end if
 

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